I just want to know how to detect internet connectivity in iOS when device is connected to wifi but no intenet connection in modem.
I have used apple's and AFNetworking's reachability but they only check for connectivity and returns connected flag even there is no working internet in modem.
I found the solution by hitting host via Reachability:-
Might be helpful for someone.
-(BOOL)isCheckConnection {
Reachability *rc = [Reachability reachabilityWithHostName:@"www.google.com"];
NetworkStatus internetStatus = [rc currentReachabilityStatus];
if(internetStatus==0)
{
//@"NoAccess";
return NO;
}
else if(internetStatus==1)
{
//@"ReachableViaWiFi";
return YES;
} else if(internetStatus==2)
{
//@"ReachableViaWWAN";
return YES;
}
else
{
//@"Reachable";
return 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