determine ios connectivity states wifi 3g

Method 1

Many people use an easy and dirty way:

([NSString stringWithContentsOfURL:[NSURL URLWithString:@""]]!=NULL)?YES:NO;

Mehthod 2 (better):

Follow following 3 easy steps –

Step 1: Include “SystemConfiguration.framework” framework in your project

Step 2: Included Apple’s Reachability.h and Reachability.m from Reachability example

Step 3: Now add this code anywhere in your .m.

Reachability* wifiReach = [[Reachability reachabilityWithHostName: @""] retain];
NetworkStatus netStatus = [wifiReach currentReachabilityStatus];

switch (netStatus)
    case NotReachable:
        NSLog(@"Access Not Available");

    case ReachableViaWWAN:
        NSLog(@"Reachable WWAN");
    case ReachableViaWiFi:
        NSLog(@"Reachable WiFi");

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s