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
- 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;
}
}
