ads

ads
[6] [top6news] [slider-top-big] [latest news]
You are here: Home / How to check network connectivity or wifi network in iPhone/iPad/iOS device?

How to check network connectivity or wifi network in iPhone/iPad/iOS device?

| No comment
SHARE


Sometimes it is required to check network connectivity because Apple rejects app when it shows error due to network connectivity.

To resolve this issue you can use these simple steps

  • Add following line check in info.plist
            NetworkRequired===>1
  • Another method you can use anywhere where you requires to check network
         
- (BOOL) connectedToNetwork
{
 Reachability *r = [Reachability reachabilityWithHostName:@"www.rayzinfotech.com"];
 NetworkStatus internetStatus = [r currentReachabilityStatus];
 BOOL internet;
 if ((internetStatus != ReachableViaWiFi) && (internetStatus != ReachableViaWWAN)) {
  internet = NO;
 } else {
  internet = YES;
 }
 return internet;
} 

-(BOOL) checkInternet
{
 //Make sure we have internet connectivity
 if([self connectedToNetwork] != YES)
 {
  [self showMessage: @"No network connection found. An Internet connection is required for this application to work"
    withTitle:@"No Network Connectivity!"];
  return NO;
 }
 else {
  return YES;
 }
}