मैं अपने अनुप्रयोग में इस का उपयोग करें:
// Check for internet connection
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil];
internetReachable = [Reachability reachabilityForInternetConnection];
[internetReachable startNotifier];
// Check if a pathway to a random host exists
hostReachable = [Reachability reachabilityWithHostName: @"www.apple.com"];
[hostReachable startNotifier];
और:
- (void) checkNetworkStatus:(NSNotification *)notice
{
// Called after network status changes
NetworkStatus internetStatus = [internetReachable currentReachabilityStatus];
switch (internetStatus)
{
// Case: No internet
case NotReachable:
{
internetActive = NO;
// Switch to the NoConnection page
NoConnectionViewController *notConnected = [[NoConnectionViewController alloc] initWithNibName:@"NoConnectionViewController" bundle:[NSBundle mainBundle]];
notConnected.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:notConnected animated:NO];
break;
}
case ReachableViaWiFi:
{
internetActive = YES;
break;
}
case ReachableViaWWAN:
{
internetActive = YES;
break;
}
}
// Check if the host site is online
NetworkStatus hostStatus = [hostReachable currentReachabilityStatus];
switch (hostStatus)
{
case NotReachable:
{
hostActive = NO;
break;
}
case ReachableViaWiFi:
{
hostActive = YES;
break;
}
case ReachableViaWWAN:
{
hostActive = YES;
break;
}
}
}
मैं इस तरह के मुद्दे का भी अनुभव करते हुए, मुझे आश्चर्य है कि लोग आमतौर पर इसका समाधान क्यों नहीं करते हैं और केवल पहुंच योग्यता का उपयोग करते हैं। मेरा मतलब है कि वहां ऐप के साथ क्या होता है यदि यह वाईफ़ाई से कनेक्ट है और इंटरनेट वास्तव में काम नहीं कर रहा है। और वे इस मामले को –