Search code examples
iosreachability

Reachability Not Detecting WiFi


I am having issues with Reachability not detecting that Wifi is active connection. I have the standard Reachability class imported in my project, and on the action I perform I detect if Wifi is available to determine which action to actually perform.

    Reachability *reachability = [Reachability reachabilityWithHostName:@"www.google.com"];
             NetworkStatus status = [reachability currentReachabilityStatus];
             NSLog(@"%i", status);
             if (status == ReachableViaWiFi) {
//do wifi action
}
else {
//do non wifi action
}

No matter what, it always performs the else action. The log for the status returns '2'. Any thoughts what may be going on?

UPDATE: After much testing, I have determined that for some reason, WWAN and WIFI are reversed on this app. When running on a real device with wifi turned off, it shows connection status as WIFI and when connected to a WIFI network it shows connection status as WWAN.


Solution

  • we took a look at the programming and narrowed it down to a switch case issue, reachability was returning 2 but the switch case inside another class returned "wwan" instead of "wifi" for case 2, please check this answer or close this question so others will not try to answer a solved problem, Thank You.