How can I detect if the phone is in airplane mode? (It's not enough to detect there is no internet connection, I have to be able to distinguish these 2 cases)


Solution 1:

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.

Solution 2:

You can add the SBUsesNetwork boolean flag set to true in your Info.plist to display the popup used in Mail when in Airplane Mode.

Solution 3:

For jailbroken tweaks/apps:

@interface SBTelephonyManager : NSObject
+(id)sharedTelephonyManager;
-(BOOL)isInAirplaneMode;
@end

...

bool isInAirplaneMode = [[%c(SBTelephonyManager) sharedTelephonyManager] isInAirplaneMode];