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

后端 未结 2 352
终归单人心
终归单人心 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:06

    There is a nice reachability example on the net. it works wonderfully well: http://servin.com/iphone/iPhone-Network-Status.html

    But you see, when I try to use it my own way, it just bombs.

    Tried to implement it using:

    NSString *sCellNetwork;     
     NSString *sNetworkReachable;  
    
    if (flags & kSCNetworkFlagsReachable || flags & kSCNetworkReachabilityFlagsIsWWAN)
    
    {do it} 
    
     else {
       Network fail alert; 
    }
    
    0 讨论(0)
  • 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];
    }
    
    0 讨论(0)
提交回复
热议问题