1

I'm researching for the best to assess the connectivity status and connection type at a given time. This will be used as a determining factor for different syncing and download capabilities available to the app's user.

If no internet access, they will only be able to create new elements in a offline sorted array. If there is internet access via a mobile data present, they can sync all lookup tables, download new data from the server, and upload data (text only). And finally, if there is internet access via a WiFi network, they will be able to sync multimedia and upload multimedia.

Currently, we're using the following factory method to determine internet access and connection type

+ (BOOL) isConnected {
Reachability *internet = [Reachability reachabilityWithHostName: @"www.google.com"];

NetworkStatus netStatus = [internet currentReachabilityStatus];
bool netConnection = false;

switch (netStatus)
{
    case NotReachable:
        {
            NSLog(@"Access Not Available");
            netConnection = false;
            break;
        }
        case ReachableViaWWAN:
        {
            NSLog(@"Reachable via Cellular Data");
            netConnection = true;
            break;
        }
        case ReachableViaWiFi:
        {
            NSLog(@"Reachable via WiFi");
            netConnection = true;
            break;
        }
    }
    return netConnection;
}

In our testing phase, we discovered an unexpected issue. The above will evaluate true for WWAN connectivity by just having a SIM card installed, even if it's a SIM card that isn't active with any carrier.

I believe that somehow (maybe we overlooked some basic thing) we're only evaluating if there COULD be a data connection instead of testing for an actual one.

How can we evaluate actual access to the internet?

PS. We're utilizing Apple's 2016 updated Reachability class

Thank you in advance for your help.

C.Islas
  • 59
  • 7
  • You should have a look at http://stackoverflow.com/questions/2995822/check-internet-connection-in-cocoa-application . – SteffX Aug 07 '16 at 16:28

0 Answers0