How to differentiate the Airplane mode from No Service from carrier with Obj-C? ?

Is it possible to differentiate whether user has no signal from carrier's mobile internet or purposefully has Airplane mode enabled?

I want to disable some features inside my app if user has Airplane mode enable. At the same time, I want to keep these same features enabled if the device simply do not have service from carrier at that moment.

platform :ios, '11.0'

Following block code with Objective C was found in a StackOverFlow post and it is helpfull but it either lack of signal from carrier or airplane mode returns as ConnectionTypeNone.

typedef enum {
    ConnectionTypeUnknown,
    ConnectionTypeNone,
    ConnectionType3G,
    ConnectionTypeWiFi
} ConnectionType;


+ (ConnectionType)connectionType
{
   SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, "8.8.8.8");
   SCNetworkReachabilityFlags flags;
   BOOL success = SCNetworkReachabilityGetFlags(reachability, &flags);
   CFRelease(reachability);
   if (!success) {
       return ConnectionTypeUnknown;
   }
   BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0);
   BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0);
   BOOL isNetworkReachable = (isReachable && !needsConnection);

   if (!isNetworkReachable) {
       return ConnectionTypeNone;
   } else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) {
       return ConnectionType3G;
   } else {
       return ConnectionTypeWiFi;
   }
}

Is it possible to differentiate whether user has no signal from carrier's mobile internet or purposefully has Airplane mode enabled?

No.

I want to disable some features inside my app if user has Airplane mode enable.

Why?

I suspect that you’re making an assumption here that isn’t valid. For example, most folks assume that Airplane mode implies that there’s no access to the Internet, but that’s not true. However, this is just a suspicion and I’d love to learn more about your specific requirements.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

How to differentiate the Airplane mode from No Service from carrier with Obj-C? ?
 
 
Q