Breaking News
Loading...
Thursday, August 1, 2013

IOS check Network availability ?

3:25 AM
It's very easy in iOS ,just we need to import SystemConfiguration.framework in our project,the we need to write below few lines in class


+ (BOOL) currentNetworkStatus {
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
BOOL connected;
BOOL isConnected;
const char *host = "www.apple.com";
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, host);
SCNetworkReachabilityFlags flags;
connected = SCNetworkReachabilityGetFlags(reachability, &flags);
    isConnected = NO;
isConnected = connected && (flags & kSCNetworkFlagsReachable) && !(flags & kSCNetworkFlagsConnectionRequired);
CFRelease(reachability);
    if (!isConnected) {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"Network connection is unavalible.please chech your connection" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
        [alert show];
    }
return isConnected;
}

Enjoy with coding ...

Next
This is the most recent post.
Older Post

0 comments:

 
Toggle Footer