Because the Flow wizard needs to monitor the traffic in the cellular data or 3G environment, it is necessary to determine the 3G environment
Add Systemconfiguration.framework to the project:
Introducing Header Files#import <systemconfiguration/systemconfiguration.h>//-to determine if the current network is available
+ (BOOL) isnetworkenabled
{
BOOL benabled = FALSE;
NSString *url = @ "www.baidu.com";
Scnetworkreachabilityref ref =scnetworkreachabilitycreatewithname (NULL, [urlutf8string]);
Scnetworkreachabilityflags flags;
benabled = Scnetworkreachabilitygetflags (ref, &flags);
Cfrelease (ref);
if (benabled) {
Kscnetworkreachabilityflagsreachable: Able to connect to network
Kscnetworkreachabilityflagsconnectionrequired: Able to connect to the network, but first to establish the connection process
Kscnetworkreachabilityflagsiswwan: Determine whether the connection is covered by a cellular network, such as Edge,gprs or the current 3G. The main difference is the connection via WiFi.
BOOL flagsreachable = ((Flags &kscnetworkflagsreachable)! = 0);
BOOL connectionrequired = ((Flags &kscnetworkflagsconnectionrequired)! = 0);
BOOL Nonwifi = Flags &kSCNetworkReachabilityFlagsTransientConnection;
benabled = ((flagsreachable &&!connectionrequired) | | nonwifi)? Yes:no;
}
return benabled;
}
As a record.
IOS Network decision