0
-(BOOL)connected
{
    Reachability *reachability = [Reachability reachabilityForInternetConnection];
    NetworkStatus networkStatus = [reachability currentReachabilityStatus];
    return !(networkStatus == NotReachable);
}


if (![self connected]) {


    NSLog(@"Not Connected");
} else {        
    NSLog(@"Connected");

    // connected, do some internet stuff
}

The above code is perfectly working with Wifi.When i use 3G connectivity it is not working correctly.I do not know how to change code for 3G connectivity.any help will be appreciated.thanks in advance.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Xcode
  • 455
  • 2
  • 5
  • 16

1 Answers1

0

Reachability is only used to detect if a system has connection to a gateway to the internet but doesn't go in-depth and check whats behind it. There a times when a LAN is reachable but there no gateway to the internet. You're have to make a actual real request to a server. Take a look at this great sample code on how to implement on all types of connectivity

Community
  • 1
  • 1
Shams Ahmed
  • 4,498
  • 4
  • 21
  • 27