5

The Reachability classes from Apple Reachability sample code seems to fire quite delayed when the user places the device into airplane mode. I am seeing roughly a 5 second gap between the user going to airplane mode and the actual notification.

Is there a quicker way to get notification? or a new way on this OS?

cynistersix
  • 1,215
  • 1
  • 16
  • 30

1 Answers1

0

I built a sample that polls the connectivity instead of relying on the notification. So by simply using the Reachability sample and checking the connectivity you can determine if you're still connected.

- (NetworkStatus)currentReachabilityStatus
{
    NSAssert(_reachabilityRef != NULL, @"currentNetworkStatus called with NULL SCNetworkReachabilityRef");
    NetworkStatus returnValue = NotReachable;
    SCNetworkReachabilityFlags flags;

    if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags))
    {
        if (_alwaysReturnLocalWiFiStatus)
        {
            returnValue = [self localWiFiStatusForFlags:flags];
        }
        else
        {
            returnValue = [self networkStatusForFlags:flags];
        }
    }

    return returnValue;
}

This way you can tell what connectivity state is instead of hoping to get the notification on time.

cynistersix
  • 1,215
  • 1
  • 16
  • 30