使用 Monotouch 在 iPhone 上切换 3G 和 WiFi
我有一个使用 MonoTouch 构建的本机应用程序,它使用 Web 服务与业务层进行通信。当设备在 3G 和 WiFi 之间切换时,我试图获得更好的行为。看来,如果应用程序以 WiFi 启动,它必须继续以 WiFi 运行,并且不能切换到 3G,反之亦然。如果我在 3G 下运行应用程序,我可以启动飞行模式来关闭连接并使用 Wifi,并且我的应用程序不会与服务通信。如果我先运行 Wifi,然后将其关闭并使用 3G,它就不会与我的服务层通信。
如果我终止该应用程序并再次启动它,它将正常工作。我什至可以使用 Safari 并通过设备上的浏览器点击相同的服务来验证是否有到达那里的路线,但我的应用程序仍然不会与服务通信,直到它返回到原始连接类型。我没有做任何事情来保持联系。只需按需打开和关闭 HttpWebRequests。网络可达性标志始终表明我有可用的路由。
在该应用程序中,人们走出连接 WiFi 的建筑物,并且可能走得足够远,以至于失去了 WiFi 和 3G 的连接。由于某种原因它不会切换,我不明白,因为我认为它应该自动发生。
I have a native app built using MonoTouch that uses web services to communicate with a business layer. I am trying to get some better behavior when the device switches between 3G and WiFi. It seems that if the app starts with WiFi it must continue to run with WiFi and cannot switch to 3G and vice versa. If I run the app under 3G I can initiate airplane mode to shut down the connection and engage Wifi and my app won't talk to the services. If I am running Wifi first and then shut it down and engage 3G it won't talk to my services layer.
If I kill the app and launch it again it will work fine. I can even engage Safari and hit the same services through the browser on the device to verify there is a route to get there, but my app still won't talk to the services until it is back on the original connection type. I am not doing anything to hold onto connections. Just opening and closing HttpWebRequests on demand. The network reachability flags always indicate I have a route available.
The application is one where people walk out of a building connected to WiFi and may walk far enough they lose the WiFi and 3G engages. It doesn't switch for some reason, which I don't understand as I thought it was supposed to happen automatically.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以确保特定站点的网络正常运行,如下所示:
You can ensure that the network to a particular site is up like this: