How to Detect Airplane Mode/ Flight Mode in IOS Sw

2019-04-07 03:42发布

问题:

I need to detect weather IPhone is in Airplane mode or Not, i have done much research and i found no direct way to achieve that . My App has the functionality of Calling a Number and When an Iphone has Airplane mode he can't call.

so I need to show him my custom Screen to Notify that Airplane mode is enable.

it will be good if any one can explain how we can achieve it in an effective way.

回答1:

Here is another way to detect this mode like below,

go Info.plist -> add this **Application uses Wi-Fi (Boolean) YES*

To test: Kill your app -> turn on airplane mode -> open ur app: you should be able to see alert within the app.



回答2:

Try using SCNetworkReachabilityGetFlags (SystemConfiguration framework). If the flags variable handed back is 0 and the return value is YES, airplane mode is turned on.

Check out Apple's Reachability classes.

There is no built-in api to determine if Airplane mode is on. You have to check if the respective services are available, depending on what you need in your app.