0
votes

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.

1
did you add SystemConfiguration framework?rezand
@rezand yes i did. The header for Reachability shows this versions: File: Reachability.h Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs. Version: 2.0.4ddg / / Significant additions made by Andrew W. Donoho, August 11, 2009. This is a derived work of Apple's Reachability v2.0 class. The below license is the new BSD license with the OSI recommended personalizations. <opensource.org/licenses/bsd-license.php>user717452
alright i havent used it yet but ive been meaning to im going to copy your code and see what results i get and how to fix if no one answers by then..rezand
What's odd is I have used this code before and never had this issue, and even in past projects with same code it doesn't behave like this.user717452
perhaps google is down for the day to mess up your programming...yeah its strange and going to be something ridiculously minor when you figure it outrezand

1 Answers

0
votes

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.