How to check if iPhone supports CDMA or GSM

前端 未结 1 813
野的像风
野的像风 2020-12-16 08:16

Is there any way to identify if iPhone supports CDMA or GSM network. Any Apple API in Objective-C which can provide this information.

相关标签:
1条回答
  • 2020-12-16 09:01

    You might examine model id with the function (credits):

    #include <sys/types.h>
    #include <sys/sysctl.h>
    NSString* machine () {
            size_t size;
    
                // Set 'oldp' parameter to NULL to get the size of the data
                // returned so we can allocate appropriate amount of space
            sysctlbyname("hw.machine", NULL, &size, NULL, 0); 
    
                // Allocate the space to store name
            char *name = malloc(size);
    
                // Get the platform name
            sysctlbyname("hw.machine", name, &size, NULL, 0);
    
                // Place name into a string
            NSString *machineid = [NSString stringWithUTF8String:name];
    
                // Done with this
            free(name);
    
            return machineid;
        }
    

    Function will return string like @"iPhone3,3" which stands for iPhone 4 (CDMA/Verizon). It might be difficult to gather full table of various model numbers. Some of the models descriptions could be found here. You'll have to expand table of models as new models will appear.

    0 讨论(0)
提交回复
热议问题