I have Reachability working exactly as suggested as in this thread.
I am using the open source Reachability. However I am not using blocks but notifications, hence the process is pretty similar to the Apple's Reachability code.
The first time I start the app, I run this and it works great.
Reachability *reachability = [reach hostReachability];
[reachability startNotifier];
The reachabilityChanged: event is firing:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachability_Changed:) name:kReachabilityChangedNotification object:nil];
However once I press the home button and come back to the app, the startNotifier
returns internally a NO instead of a YES.
// Set it as our reachability queue, which will retain the queue
if(!SCNetworkReachabilitySetDispatchQueue(self.reachabilityRef, self.reachabilitySerialQueue))
{
#ifdef DEBUG
NSLog(@"SCNetworkReachabilitySetDispatchQueue() failed: %s", SCErrorString(SCError()));
#endif
...
return NO;
and hence the event above is never fired again.
Unless I am using this wrongly and startNotifier
should only be called once in init
when reachability is instantiated and never again?
self.hostReachability = [Reachability reachabilityWithHostname:_HOST];