简体   繁体   中英

Iphone Internet Connection Verification - Reachability

I read there were many problem with the Reachability sample app that apple provided, but now with their new 2.2 implementation it's suppose to work fine.

So I just want an advice before I integrate it into my app instead of my current implementation.

Basically I'm asking 2 question:

  1. Will this code work ? I need to know if internet is available through 3G or WIFI. (If there is a WIFI with no internet, of course I need it to return false)

2.I'm planning to deploy my app on ios 3.0 and above, do I need to perform any adjustments so it won't crash on ios below 4.0 (cause Reachability 2.2 said to be working on ios 4) ?

Thanks alot!!

+ (BOOL) isInternetReachable
{
    NetworkStatus status = [[Util sharedReachability] currentReachabilityStatus];

    return (status != NotReachable);
}

+ (Reachability*) sharedReachability
{
    if (reachability == nil)
    {
        reachability = [[Reachability reachabilityForInternetConnection] retain];   
        [reachability startNotifier];
    }
    return reachability;
}

Yes this code is gonna work. It is right.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM