这对他们来说是一种烦恼,我想阻止这些对话并简单地跳过整个数据交换的事情.
有Apple’s Reachability Sample Code.
但是虽然我关闭了整个设备的WiFi和应用程序的移动数据,但Reachability确认了一个积极的互联网连接.更具体地说,它报告
Reachability Flag Status: WR t------ networkStatusForFlags
无论我是否激活了细胞数据.当然,当蜂窝数据关闭时,实际上没有互联网连接可用,因此数据交换失败.但无论如何,用户都会看到蜂窝数据对话框.
有没有办法检测iOS 7和iOS 8上的互联网连接是否可用,考虑到特定应用程序的蜂窝数据设置 – 所有这些都不会再次通过蜂窝数据对话框窃听用户?
我的应用程序目前没有任何设置面板,所以我想避免设置(第二个应用程序内)开关“不要使用手机数据”.此外,我不想将数据交换限制为WiFi连接,因为每个会话只有2 KB的数据,这对大多数用户来说并不是一件大事.
解决方法
Apple说(https://devforums.apple.com/message/1059332#1059332):
Another developer wrote in to DTS and thus I had a chance to
investigate this in depth. Alas,the news is much as I expected:
there is no supported way to detect that your app is in this state.
Nor is there a way to make a “no user interaction” network connection,
that is,request that the connection fail rather than present UI like
this.
http://www.splinter.com.au/how-to-ping-a-server-in-objective-c-iphone/
http://elbsolutions.com/projects/reachability-with-simpleping-wrapper/