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:@"www.google.com"];
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];