I have searched but have not found an issue like mine. I'm sure it's something I have over looked .
I am using tony million's reachability block method. it is working good when i have internet then no internet. the alert comes up and works just fine.
but, when i have no internet and then i get internet the same alert pops up
my code is
-(void)reachabilityBlock
{
// allocate a reachability object
Reachability * reach = [Reachability reachabilityWithHostname:@"www.google.com"];
// tell the reachability that we DONT want to be reachable on 3G/EDGE/CDMA
reach.reachableOnWWAN = YES;
reach.reachableBlock = ^(Reachability * reachability)
{
dispatch_async(dispatch_get_main_queue(), ^{
//NSLog(@"REACHABLE! block");
[self newsTableViewRefresher];
});
};
reach.unreachableBlock = ^(Reachability * reachability)
{
dispatch_async(dispatch_get_main_queue(), ^{
//NSLog(@"UNREACHABLE! block");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"No Network found!"
message: @"You have no wifi or cellular connection available. Please connect to a WIFI or cellular network."
delegate: self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
});
};
[reach startNotifier];
[self.refreshControl endRefreshing];
}
my question is why when i get internet does the unreachable alert pop up?
thank you for your time
This is what I did on my end and got the job done for me. I try using the blocks but it seems it was more trouble that solving my issue. Hope this helps.
Reachability *reach = [Reachability reachabilityWithHostname:@"www.jportdev.com"];
if ([reach isReachable]){
// Reachable
//NSLog(@"is reachable.......");
}else{
// not Reachable
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Network is unavaliable!" message:@"Some content in this application might not be avaliable without network connectivity." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
alert = nil;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With