如何检查ios wifi,LTE,3G网络检查

时间:2016-09-24 05:37:07

标签: ios objective-c reachability

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连接?

0 个答案:

没有答案