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;
   }
}

Replies

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"

  • Basically, these users have a tendency to use Airplane mode to bypass some functions. They put a fake scenario like they were offline and could not send the information in time for deadline, but they purposefully when Airplane mode to avoid connection checking. It is definitely an ethical problem with users doing non-compliance actions.

  • In an old Android-only project, I was able to block those behaviours with no further issues, but with more recent frameworks and O.S., seems like these requirement is not possible to do. I've tried to search any way of disabling malpratices but it is not possible. Thanks for your input.

  • Basically, these users have a tendency to use Airplane mode to bypass some functions. They put a fake scenario like they were offline and could not send the information in time for deadline. It’s an ethical issue we tried to stop users from any malpractice.