0

I'm having this really weird issue with Reachability on iOS. If I run my app in debug on a device there's no problem at all, the app runs fine. But when I install it from the store or from TestFlight I get my No Coverage error even if I'm on Wi-Fi, but only when I try to do certain actions. If I don't do that specific action the app runs fine until I do.

This is the part of my code that deals with Reachability:

- (void)connectionReachabilityChanged:(NSNotification *)notice {
  NetworkStatus status = [self.connectionReachability currentReachabilityStatus];
  if (status == NotReachable) {
    self.inCoverage = NO;
  } else {
    self.inCoverage = YES;
  }
}

- (void)hostReachabilityChanged:(NSNotification *)notice {
  NetworkStatus status = [self.hostReachability currentReachabilityStatus];
  if (status == NotReachable) {
    self.inCoverage = NO;
  } else {
    self.inCoverage = YES;
  }
}

- (void)displayAlertOfType:(AlertType)type {
  if (type == AlertTypeNoCoverage) {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"No coverage"
                                                    message: @"You current have no data coverage, try again later"
                                                   delegate: self
                                          cancelButtonTitle: @"OK"
                                          otherButtonTitles: nil];
    [alert show];
  }

  if (type == AlertTypeOperationNotCompleted) {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Whoops... Something went wrong" 
                                                    message:@"The operation couldn't be completed, try again later" 
                                                   delegate:self 
                                          cancelButtonTitle:@"OK" 
                                          otherButtonTitles:nil];
    [alert show];
  }

}
8vius
  • 5,786
  • 14
  • 74
  • 136
  • What is that "Specific Action". – iProgrammed Jan 25 '13 at 18:12
  • Unasociating a social network account, or associating it. It has nothing different than any other net call, but for some reason it goes crazy with it. – 8vius Jan 25 '13 at 19:49
  • How strong is the WiFi signal. – iProgrammed Jan 25 '13 at 20:12
  • Full strength, it's my home network. The thing is if I install the app by compiling it with Xcode it works fine, but form TestFlight or the App Store it fails, even if the archive is the exact same build. – 8vius Jan 25 '13 at 20:21
  • You should contact Apple. – iProgrammed Jan 25 '13 at 20:22
  • Also try to run your app with wifi disabled and only 4G or 3G. – iProgrammed Jan 25 '13 at 20:25
  • It's the same result works fine when compiled from Xcode and goes haywire when downloaded. – 8vius Jan 25 '13 at 20:31
  • Compiled in Debug... Or Release mode? Build to release... And check your local ipa file. – TonyMkenu Jan 26 '13 at 07:03
  • You are not the only one http://stackoverflow.com/a/14230961/1702413 – TonyMkenu Jan 26 '13 at 07:05
  • How can I build to release? I'm not sure how to change that setting. – 8vius Jan 30 '13 at 19:32
  • you can set on your target: Optimization Level set to Fastest, Smallest [-Os] in Debug mod (from None) - the same as Release; in that way you can simple "Run" on Device - to more closely simulate the code that will be generated & running on the user’s device. – TonyMkenu Jan 31 '13 at 05:23
  • maybe is not debug/release issue. The same behavior here: "was from..some problem with WWAN.. there was no SIM card. Restarted the iPad & switched OFF & ON the Wi Fi again. Now it works fine" http://stackoverflow.com/questions/13247139/reachability-working-on-simulator-but-not-on-device – TonyMkenu Feb 08 '13 at 11:38

1 Answers1

0
 Reachability *reachability = [Reachability sharedReachability];
 [reachability setHostName:@"http://www.google.com/"]; 
 NetworkStatus remoteHostStatus = [reachability remoteHostStatus];

if(remoteHostStatus == NotReachable) {
 //no internet connection

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"No coverage"
                                                    message: @"You current have no data coverage, try again later"
                                                   delegate: self
                                          cancelButtonTitle: @"OK"
                                          otherButtonTitles: nil];
    [alert show];
 }
 else if (remoteHostStatus == ReachableViaWiFiNetwork) {
 //wifi connection found
 }
 else if (remoteHostStatus == ReachableViaCarrierDataNetwork) {
 //EDGE or 3G connection found
 }
iProgrammed
  • 980
  • 2
  • 10
  • 29