0

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

Community
  • 1
  • 1
work_gg
  • 99
  • 1
  • 11
  • You must test this on device and it will work fine. On simulator you networkInfo is null in any case. – Adeel Ur Rehman Jun 16 '15 at 08:31
  • ok great, do you happen to know what format the output will be, the project is to be archived and sent to client so i will not be able to test it on a device on my end (i have the wrong provisioning profiles to build to device) – work_gg Jun 16 '15 at 08:33
  • I am not sure about that right now but it will only work on device. – Adeel Ur Rehman Jun 16 '15 at 08:34

3 Answers3

2

Santu C is right.

and

//2G
CTRadioAccessTechnologyGPRS          
CTRadioAccessTechnologyEdge

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

//4G
CTRadioAccessTechnologyLTE
Community
  • 1
  • 1
Reming Hsu
  • 2,215
  • 15
  • 18
  • 1
    Not that I don't disagree @Reming but could you give credit to how you know these match with the listed network types? Is it listed on apple docs, or wiki elsewhere? – John Shelley Oct 26 '15 at 20:56
0

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.

Santu C
  • 2,644
  • 2
  • 12
  • 20
  • Since the strings all start out the same, why not just trim the leading 17 characters and keep the rest? That big else if block does not dynamically account for future technological advances & additions. – Clint StLaurent Sep 13 '16 at 14:57
-2

enter image description here

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

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Gavin
  • 1,032
  • 7
  • 13