IOS determines the network environment and ios Network Environment

Source: Internet
Author: User

IOS determines the network environment and ios Network Environment

Https://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html

I downloaded vertion2.2.

 

 

When developing Web and other network applications, you must confirm the network environment, connection conditions, and other information. If they are not processed, they will not pass Apple's review.

Reachability

Apple's routine Reachability describes how to obtain/detect the network status.

Use in your program

1. Reachability only copies the Reachability. h and Reachability. m in this routine to your project. 2. Add SystemConfiguration. framework to the project.

Three Network statuses are defined in Reachability.

Typedefenum {

NotReachable = 0, // No connection

ReachableViaWiFi, // use 3G/GPRS network

ReachableViaWWAN // use WiFi

 

} NetworkStatus;

 

Simple judgment of Project connection:

// Whether wifi is enabled

+ (BOOL) IsEnableWIFI {

Return ([[Reachability reachabilityForLocalWiFi] currentReachabilityStatus]! = NotReachable );

}

// Whether the network is connected

+ (BOOL) IsEnableConnection {

Return ([[Reachability reachabilityForInternetConnection] currentReachabilityStatus]! = NotReachable );

}

 

// Whether the network is connected

+ (BOOL) IsEnable3G {

Return ([[Reachability reachabilityForInternetConnection] currentReachabilityStatus] = ReachableViaWWAN );

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.