5

I am checking the status of internet reachability using class "Reachability". But while testing, if I am setting 100% packet loss in developer settings, still I get reachability status as "ReachableViaWiFi". I am confused what's happening. Shouldn't it be "NotReachable" in that situation ?

Here is my code snippet:

Reachability *networkReachability = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [networkReachability currentReachabilityStatus];

if(networkStatus == NotReachable){
    NSLog(@"NotReachable");
}
else if(networkStatus == ReachableViaWiFi){
    NSLog(@"ReachableViaWiFi");
}
else if(networkStatus == ReachableViaWWAN){
    NSLog(@"ReachableViaWWAN");
}

Is there any other way that give me status as FALSE in this situation?

halfer
  • 19,824
  • 17
  • 99
  • 186
NSPratik
  • 4,714
  • 7
  • 51
  • 81

2 Answers2

4

The number of packets that you lose doesn't influence reachability. After all, this could be just momentary (you took your phone into a shielded room, or a heavy electrical motor was just turned on). Reachability is about your WiFi, or 3G, or Ethernet on a Mac, being turned on. It's not about the quality of the connection.

gnasher729
  • 51,477
  • 5
  • 75
  • 98
-1

This worked for me:

-(BOOL)connected
{
    Reachability *r = [Reachability reachabilityWithHostName:@"www.google.com"];
    NetworkStatus internetStatus = [r currentReachabilityStatus];

    if ((internetStatus != ReachableViaWiFi) && (internetStatus != ReachableViaWWAN))
    {
        return NO;
    }
    else
    {
        return YES;
    }
}
NSPratik
  • 4,714
  • 7
  • 51
  • 81