Determining when an EDGE connection comes back after a dropout on an iPhone

后端 未结 2 354
终归单人心
终归单人心 2021-01-31 00:33

I\'ve incorporated Apple\'s Reachability sample into my own project so I know whether or not I have a network connection - if I don\'t have a network connection, I don\'t bother

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-31 01:10

    Reachability notificataions didn't seem to be reliable for me either, for detecting Wi-Fi. So I just use polling instead. Checking every 5 seconds seems to do no harm.

    - (void) checkReachability {
        BOOL connected = ([[Reachability sharedReachability] localWiFiConnectionStatus] == ReachableViaWiFiNetwork);
    
        // Do something...
    
        [self performSelector:@selector(checkReachability) withObject:nil afterDelay:5.0];
    }
    

提交回复
热议问题