Jon Setting Jon Setting - 1 month ago 30
iOS Question

Can an app request airplane mode to be turned ON then detect the user has done so?

I am building an app that should only be used if airplane mode is activated. The app is for people that are not tech savvy to say the very least. Therefore, I cannot expect them to swipe up and click the airplane icon. What is the closest I can get to simply turning on airplane mode form within my app?

Basically, I am looking for the opposite of UIRequiresPersistentWifi.


There's currently no public API for direct checking whether the airplane mode is on.

The closest solution would be to use the SystemConfiguration framework and monitor whether the device can connect to the network.

Using the Reachability class (by tonymillion) you can do something like

Reachability* reach = [Reachability reachabilityWithHostname:@""];
reach.reachableBlock = ^(Reachability*reach) {
    // do something to prevent the app to be used
    // NOTE: this block is called on a background thread
    // so if you need to change the UI, do 
    dispatch_async(dispatch_get_main_queue(), ^{
        // UI related stuff
reach.unreachableBlock = ^(Reachability*reach) {
    // ok continue using the app
[reach startNotifier];