Limit application capabilities in IOS to only work with Cell/WiFi data.

拜拜、爱过 提交于 2019-12-22 09:45:01

问题


I have searched all over StackOverFlow but did not find any answer on how to use Required Device Capabilities or UIRequiresPersistentWiFi.

How do I set values in my application such that the app only works on cellular data/WiFi in the iPhone?

Currently I have set the string WiFi property in the Required Device Capabilities Array according to iOSDeviceCompatibility.

Is this the correct approach or should I set UIRequiresPersistentWiFi BOOL to YES?


回答1:


Based on the documentation, setting this flag only makes sure that the device attempts to open a Wi-Fi connection. I'm not sure that it will guarantee that your networking will only occur on the Wi-Fi.

There's a class out there by apple called Reachability. https://developer.apple.com/Library/ios/samplecode/Reachability/Introduction/Intro.html

There's also a reachability class in AFNetworking 2 https://github.com/AFNetworking/AFNetworking

I would set your UIRequiresPersistentWiFi flag to YES and then check the reachability class that there is a wi-fi connection available. If not, show an error.



来源:https://stackoverflow.com/questions/22779397/limit-application-capabilities-in-ios-to-only-work-with-cell-wifi-data

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