如何获取运营商网络的连接类型?
How can i get the type of connection of a carrier network?
Reachability
类获取连接是 WIFI 还是 WWAN 我可以获取网络标志
Reachability
class I'm able to get network flags
可达性标志状态:WR t------ localWiFiStatusForFlags
Reachability Flag Status: WR t------ localWiFiStatusForFlags
我可以使用 CaptiveNetwork
支持的接口:(en0)
Supported interfaces: ( en0 )
en0 => {
BSSID = "xx:xx:xx:xx:xx:xx";
SSID = MyWifiNetwork;
SSIDDATA = <x1x1x1x1 x1x1x1x1 x1>;
}
但我无法区分 3G、EDGE 或 GPRS 连接.
But i'm not able to differenziate 3G, EDGE or GPRS connection.
知道也使用 iOS 私有 API 吗?
谢谢.
从iOS 7 开始可以使用:
From iOS 7 on you can use:
CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new];
NSLog(@"Current Radio Access Technology: %@", telephonyInfo.currentRadioAccessTechnology);
[NSNotificationCenter.defaultCenter addObserverForName:CTRadioAccessTechnologyDidChangeNotification
object:nil
queue:nil
usingBlock:^(NSNotification *note)
{
NSLog(@"New Radio Access Technology: %@", telephonyInfo.currentRadioAccessTechnology);
}];
我还发现这可以检测慢速或快速连接:
I have also found this to detect a slow or fast connection:
- (BOOL)isFast:(NSString*)radioAccessTechnology {
if ([radioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) {
return NO;
} else if ([radioAccessTechnology isEqualToString:CTRadioAccessTechnologyEdge]) {
return NO;
} else if ([radioAccessTechnology isEqualToString:CTRadioAccessTechnologyWCDMA]) {
return YES;
} else if ([radioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSDPA]) {
return YES;
} else if ([radioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSUPA]) {
return YES;
} else if ([radioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMA1x]) {
return NO;
} else if ([radioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0]) {
return YES;
} else if ([radioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA]) {
return YES;
} else if ([radioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB]) {
return YES;
} else if ([radioAccessTechnology isEqualToString:CTRadioAccessTechnologyeHRPD]) {
return YES;
} else if ([radioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) {
return YES;
}
return YES;
}
这篇关于检测运营商连接类型(3G/EDGE/GPRS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!