I am trying to detect the internet is working or not on the device using AFNetworking
; referred to the answer here on the SO
AFNetworking 2.0 Reachability . I am able to detect device is connected with WiFi or 3G..
The problem is Actually internet is not working like the WIFI is on but internet is not working.
How Can i detect internet is working .Like we check using ping....
I am checking using the following
-(BOOL)connected {
__block BOOL reachable;
// Setting block doesn't means you area running it right now
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
switch (status) {
case AFNetworkReachabilityStatusNotReachable:
NSLog(@"No Internet Connection");
reachable = NO;
break;
case AFNetworkReachabilityStatusReachableViaWiFi:
NSLog(@"WIFI");
reachable = YES;
break;
case AFNetworkReachabilityStatusReachableViaWWAN:
NSLog(@"3G");
reachable = YES;
break;
default:
NSLog(@"Unkown network status");
reachable = NO;
break;
}
}];
// and now activate monitoring
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
return reachable;
}