In my iOS app, I'm trying to monitor Internet connectivity. I display an alert if the user is not connected to the Internet. However, I'm finding that the alert can take a very long time to be visible, on the order of 30 seconds. Is there some other way to more quickly display an alert if a user is not connected?
I'm testing with my iPhone 5S on airplane mode.
- (void)viewDidLoad
{
[super viewDidLoad];
Reachability *internetConnection = [Reachability reachabilityWithHostname:@"www.google.com"];
// Internet is not reachable
internetConnection.unreachableBlock = ^(Reachability*reach)
{
disconnected = YES;
NSLog(@"no network connection");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No network connection"
message:@"You must be connected to the internet to use this app."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
};