Can I prevent iPhone from using 3G under any circumstances?

人盡茶涼 提交于 2020-01-02 01:12:14

问题


I'm writing a travel guide related app that will download large databases (60meg) potentially overseas, with the reachability code I can tell when a host is reachable via wifi or 3g BUT I'm worried that if for some reason the wifi connection breaks for a minute or so as some DSL connections are likely to do on occasion the iphone will switch transparently to 3G and without realising I could be racking up someones phone bill with overseas data charges!

So I'm wondering if anyone has any experience, in the event of such break in wifi connectivity (wifi still works but it's connection to the net is down) would the reachability code report ReachableViaWWAN? So I could wait till my download code returns, check how the host is currently reachable and if it's via 3g I could abort?

Is it possible to select what type of connection I can use aka 3g or wifi exclusively?


回答1:


If you look in the Reachability sample, in Reachability.h, there's a constant defined as "kReachabilityChangedNotification." If you ask to be notified of changes—assuming that this works as it sounds like it does—you could stop the connection when it drops down to 3G.




回答2:


Under Settings->General->Network there is "Data Roaming". This allows you to turn off roaming onto other data networks when traveling internationally. The user already has a choice there whether to allow expensive 3G connections when traveling.




回答3:


Yes, under settings->general->network, you can shut-off 3G. But the iphone will still use non-3G cellular.

Alternatively, when I travel overseas I put the iPhone in airplane mode, and then turn wi-fi on manually.




回答4:


No; Unix-style IP doesn't work like that. Using the reachability code will do mostly the right thing, but there's still a chance you'll send a few packets over 3G before you handle the notification.

It's probably safe to assume that users who don't turn off "data roaming" will do so very quickly. On the other hand, many users won't have unlimited internet plans.

One option is to display something like "Not connected over Wi-Fi, do you want to download lots of data over the cell network? You might be charged." and store it in a setting.



来源:https://stackoverflow.com/questions/3023404/can-i-prevent-iphone-from-using-3g-under-any-circumstances

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!