etworkStatus netStatus = [[Reachability reachabilityForInternetConnection] currentReachabilityStatus];
CTTelephonyNetworkInfo *networkInfo = [[CTTelephonyNetworkInfo alloc] init];
NSString* statusString= @"";
// LTE Check
if([networkInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]){
statusString = @"LTE";
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:[OTPAppDelegate getAppTitle]
message: statusString
delegate: self
cancelButtonTitle:CONFIRM otherButtonTitles: nil];
[alertView show];
return YES;
}
// network check
switch (netStatus)
{
case NotReachable:
{
statusString = NETWORK_ERROR;
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:[OTPAppDelegate getAppTitle]
message: statusString
delegate: self
cancelButtonTitle:CONFIRM otherButtonTitles: nil];
[alertView show];
return YES;
break;
}
case ReachableViaWWAN:
{
// statusString = @"GRPS/3G Connect.";
return NO;
break;
}
case ReachableViaWiFi:
{
// statusString= @"WiFi Connect.";
statusString = WIFI_CHECK;
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:[OTPAppDelegate getAppTitle]
message: statusString
delegate: self
cancelButtonTitle:CONFIRM otherButtonTitles: nil];
[alertView show];
return YES;
break;
}
}
return NO;
}
我尝试了这个来源。但失败
在iOS模拟器中,networkInfo.currentRadioAccessTechnology值不是LTE
但在真实的iOS设备中,
networkInfo.currentRadioAccessTechnology价值始终是LTE。
如何在iOS中检查LTE连接?