2

Is it possible to determine the iPhone 4s's network type (GSM/CDMA)? Is there a way to determine the iPhone 4s's network type (GSM/CDMA).I want to distinguish between GSM/WCDMA and CDMA if possible. I use the following codes to detect it .

    size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithUTF8String:machine];
if ([platform isEqualToString:@"iPhone4,1"])    return @"iPhone 4S";
if ([platform isEqualToString:@"iPhone4,3"])    return @"iPhone 4S coma";

But I test it with my coma and wcdma iphone4s。 It both return iPhone4,1. I can not distinguish it.

duoduomobile
  • 99
  • 2
  • 6

1 Answers1

0

You could use the carrier that is being used as an indicator.

NSString* networkType = nil;

// Setup the Network Info and create a CTCarrier object
// first check to ensure the developper linked the CoreTelephony framework
Class telephonyClass = NSClassFromString(@"CTTelephonyNetworkInfo");
if ( nil != telephonyClass ) {
    CTTelephonyNetworkInfo *networkInfo = [[[telephonyClass alloc] init] autorelease];

    if ( nil != networkInfo ) {
       // Get mobile network code
        NSString *mnc = [carrier mobileNetworkCode];
        if (mnc != nil) {   
             // set networkType based on carrier name
             // carrier name to network type mapping left as an exercise for the reader
             //
        }
    }
}
kamprath
  • 2,220
  • 1
  • 23
  • 28