I have this code in my app:
-(void)reachAlert:(Reachability*)currentReach {
if(currentReach == hostReach) {
//Make sure we have internet connectivity
//UIAlertView *internetAlert = [[UIAlertView alloc] initWithTitle:@"Excellent" message:@"Host Reached" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
//[internetAlert show];
[[SDSyncEngine sharedEngine] startSync];
}
/**
if(currentReach == internetReach) {
//Make sure we have internet connectivity
UIAlertView *internetAlert = [[UIAlertView alloc] initWithTitle:@"Good"
message:@"Internet"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Ok", nil];
[internetAlert show];
}
**/
if(currentReach == wifiReach) {
//Make sure we have internet connectivity
UIAlertView *internetAlert = [[UIAlertView alloc] initWithTitle:@"Bad News"
message:@"Only wifi"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Ok", nil];
[internetAlert show];
}
[TestFlight passCheckpoint:@"reachAlert"];
}
As you can see I commented out internetReach because I figured, whats more important is that we have hostReach. Thus by default we must have internet reach. I also commented out the hostReach alert only because I only want to alert the user in case of NO internet connectivity.
However when testing the app on wifi, i get the bad news only wifi message. Why doesnt it give the hostReach alert?
Reachability is really not ideal for displaying error messages. Ideally you should show an error message when the connection you are trying to use fails, for example NSURLConnection returning a -1009 error.