CTTelephonyNetworkInfo detect data type

2.4k views Asked by At

I have implemented CTTelephonyNetworkInfo as per CTTelephony

my code

CTTelephonyNetworkInfo  *networkInfo = [[CTTelephonyNetworkInfo alloc] init];
NSLog(@"Initial cell connection: %@", networkInfo.currentRadioAccessTechnology);

I haven't been able to get anything back and my 'Initial cell connection ' always returns null. I am running on simulator which is set to wifi (this i presume is why null is displayed). I want to use CTTelephony to detect and return if the connection is 3g or 4g and return either '3g' or '4g' as a string value

3

There are 3 answers

1
Santu C On

You may use below category on CTTelephonyNetworkInfo to get currentRadioAccessTechnology.

#import "CTTelephonyNetworkInfo+CellularConnectionNiceName.h"

@implementation CTTelephonyNetworkInfo (CellularConnectionNiceName)


- (NSString *)cellularConnectionNiceName {

    if ([self.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) {
        return @"GPRS";
    } else if ([self.currentRadioAccessTechnology  isEqualToString:CTRadioAccessTechnologyEdge]) {
        return @"EDGE";
    } else if ([self.currentRadioAccessTechnology  isEqualToString:CTRadioAccessTechnologyWCDMA]) {
        return @"WCDMA";
    } else if ([self.currentRadioAccessTechnology  isEqualToString:CTRadioAccessTechnologyHSDPA]) {
        return @"HSDPA";
    } else if ([self.currentRadioAccessTechnology  isEqualToString:CTRadioAccessTechnologyHSUPA]) {
        return @"HSUPA";
    } else if ([self.currentRadioAccessTechnology  isEqualToString:CTRadioAccessTechnologyCDMA1x]) {
        return @"CDMA1X";
    } else if ([self.currentRadioAccessTechnology  isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0]) {
        return @"CDMAEVDOREV0";
    } else if ([self.currentRadioAccessTechnology  isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA]) {
        return @"CDMAEVDOREVA";
    } else if ([self.currentRadioAccessTechnology  isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB]) {
        return @"CDMAEVDOREVB";
    } else if ([self.currentRadioAccessTechnology  isEqualToString:CTRadioAccessTechnologyeHRPD]) {
        return @"EHRPD";
    } else if ([self.currentRadioAccessTechnology  isEqualToString:CTRadioAccessTechnologyLTE]) {
        return @"LTE";
    }
    return @"UNKNOWN";
}

Note : CTTelephonyNetworkInfo framework is work on Device Only.

1
Reming Hsu On

Santu C is right.

and

//2G
CTRadioAccessTechnologyGPRS          
CTRadioAccessTechnologyEdge

//3G
CTRadioAccessTechnologyWCDMA         
CTRadioAccessTechnologyHSDPA   
CTRadioAccessTechnologyHSUPA     
CTRadioAccessTechnologyCDMA1x    
CTRadioAccessTechnologyCDMAEVDORev0    
CTRadioAccessTechnologyCDMAEVDORevA 
CTRadioAccessTechnologyCDMAEVDORevB
CTRadioAccessTechnologyeHRPD

//4G
CTRadioAccessTechnologyLTE
0
Gavin On

enter image description here

Here is the link to technologies behind 2G, 3G, 4G. I believe @Reming Hsu 's answer is correct.