简体   繁体   中英

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

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM