objective-c - 是否可以在iOS5中确定iPhone 4s的网络类型(GSM/CDMA)

标签 objective-c ios ios5 ios4

是否可以确定iPhone 4s的网络类型(GSM / CDMA)?
有没有办法确定iPhone 4s的网络类型(GSM / CDMA)。我想尽可能地区分GSM / WCDMA和CDMA。我使用以下代码进行检测。

    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";

但是我用昏迷和wcdma iphone4s进行了测试。
它们都返回iPhone4,1。我无法区分。

最佳答案

您可以使用被用作指示器的载体。

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
             //
        }
    }
}

关于objective-c - 是否可以在iOS5中确定iPhone 4s的网络类型(GSM/CDMA),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11416109/

相关文章:

ios - 从网页 iOS 中的文本字段获取字符串

objective-c - iOS:UIPopoverController 内的人物选择器,搜索键盘扭曲弹出框

ios - 使用 AsyncImageView 将图像加载到 ImageView 宽度

ios - 如何随机给 UILabel 上色

objective-c - 实现音量控制

iphone - 如何按日期获取日历事件?

android - 在 Titanium 中的选项卡组上方创建标题栏

ios - 不使用 Interface Builder 制作通用应用程序

iphone - 有条件地包含用于不同 iOS SDK 版本的库?

iOS 应用程序无法在设备上编译,但在模拟器中运行良好