Crystal
Crystal

Reputation: 29458

Problems with Reachability in iOS 5.1?

We were using Apple's Reachability a few months ago to check for the network status of the iPad. It worked before. Now when I try to test for it, I always get network unreachable and am wondering why. Any thoughts on this? Here's some of my code:

// In the class I want to check for reachability to send email from, I access my singleton object WebServiceManager
WebServiceManager *wmgr = [WebServiceManager sharedInstance];
[wmgr CheckNetworkStatus];

if (wmgr.isInternetAvailable) {        
    if ([MFMailComposeViewController canSendMail]) {
        MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
        mailComposer.mailComposeDelegate = self;

        [self presentModalViewController:mailComposer animated:YES];
    }
    else {
        UIAlertView *mailNotConfiguredAlert = [[UIAlertView alloc] initWithTitle:@"This device is not configured to send mail" message:@"Please set up your mail account in order to send an email." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [mailNotConfiguredAlert show];
        [mailNotConfiguredAlert release];
    }
}
else {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Network Connection Unavailable" message:@"The network connection is currently unavailable.  Please try again later." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
    [alert show];
    [alert release];      
}

// In WebServiceManager

- (void)CheckNetworkStatus {
NetworkStatus internetStatus = [_networkReachable currentReachabilityStatus];
switch (internetStatus)
{
    case NotReachable:
    {
        isInternetAvailable = NO;
        break;
    }
    case ReachableViaWiFi:
    {
        isInternetAvailable = YES;
        break;
    }
    case ReachableViaWWAN:
    {
        isInternetAvailable = YES;
        break;
    }
}

}

Upvotes: 0

Views: 285

Answers (1)

Bojan Dimovski
Bojan Dimovski

Reputation: 1216

Probably it's not Reachability, we're using it in 5.1 at the moment and it doesn't produce any weird behavior.

Check if your boolean property isInternetAvailable is being set properly (probably some NSLog debugging would help).

Upvotes: 1

Related Questions