I am facing weird problem on iPhone 5 with iOS 7, i have tested same code with other devices like iPad1, 2, 3 and iPhone 4, 4s etc. with different iOS combination including iOS 7.
Problem :
When i turn on airplane mode i do get reachability notification as expected with status NotReachable
but immediately after that app receives notification with status code ReachableViaWWAN
which is not expected.
Code :
+(BOOL)checkReachability
{
Reachability* internetReachable = [Reachability reachabilityForInternetConnection];
NetworkStatus internetStatus = [internetReachable currentReachabilityStatus];
switch (internetStatus)
{
case NotReachable:
{
DebugLog(@"The internet is down.");
return NO;
break;
}
default:
return YES;
break;
}
return YES;
}
I added log before switch which is returning status as ReachableViaWWAN
in airplane mode..
Possible workaround could be:
Add case for ReachableViaWWAN
and check host reachable in that case. And return BOOL value accordingly.
Anyone faced similar problem ?? i have searched but haven't found similar scenario.
Thanks in advance !!
I had the same problem. The solution is to check the flag isConnectionRequired. The documentation says:
WWAN may be available, but not active until a connection has been established.
BOOL isServerAvailable;
Reachability *reachability = [Reachability reachabilityForInternetConnection];
if ((reachability.isConnectionRequired) || (NotReachable == reachability.currentReachabilityStatus)) {
isServerAvailable = NO;
} else if((ReachableViaWiFi == reachability.currentReachabilityStatus) || (ReachableViaWWAN == reachability.currentReachabilityStatus)){
isServerAvailable = YES;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With