5

My question is same as this question, but don't get a proper answer.

If I am connected to wifi, but internet is not available/gone it should be notify. Alslo tested using Apple Reachability demo but still its not working.

Steps to reproduce:

1) connect iPhone using tethering on another device.

2) run the apple rechability demo.

3) turn off the cellular data on another device on wich iPhone is connected.

Community
  • 1
  • 1
Dinesh Kachhot
  • 385
  • 5
  • 15

1 Answers1

-2

You can simply call the below code and then call NSURLConnection delegate methods. This way even if wifi is connected and internet not available it can be detected.

NSMutableURLRequest *headerRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"] cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:10.0];
    headerRequest.HTTPMethod = @"HEAD";
    self.headerConnection = [[NSURLConnection alloc] initWithRequest:headerRequest delegate:self];
Subin
  • 353
  • 2
  • 11