I am using my app and Internet connection is disable. Next, I am going to enable my Internet connection. Now how can I find that my Internet connection is enabled or not without doing anything in my app?
I am working in obj-c.
I am using my app and Internet connection is disable. Next, I am going to enable my Internet connection. Now how can I find that my Internet connection is enabled or not without doing anything in my app?
I am working in obj-c.
import Reachability.h
file from here and do like following:
if ([[Reachability reachabilityForInternetConnection]currentReachabilityStatus]==NotReachable)
{
//Do here what you want to do when connection unavailable
}
else
{
//Do here what you want to do when connection available
}
Use this method
+(BOOL)isNetAvailable
{
CFNetDiagnosticRef dReference;
dReference = CFNetDiagnosticCreateWithURL (NULL, (__bridge CFURLRef)[NSURL URLWithString:@"www.apple.com"]);
CFNetDiagnosticStatus status;
status = CFNetDiagnosticCopyNetworkStatusPassively (dReference, NULL);
CFRelease (dReference);
if ( status == kCFNetDiagnosticConnectionUp )
{
NSLog (@"Connection is Available");
return YES;
}
else
{
NSLog (@"Connection is down");
return NO;
}
}