MobileCOuntryCode iOS 不工作

1 mobile-country-code ios

从下面的帖子中我试图检测iPhone 中的SIM 卡

以编程方式检测 iPhone 中的 Sim 卡是否可用

我尝试了您提供的相同代码,但它总是返回我(空)。我已添加core telephony framework并导入CTCarrier.h文件。我还有什么需要做的吗?

谢谢

vin*_*nan 5

#import <CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>

CTTelephonyNetworkInfo* info = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier* _carrier = info.subscriberCellularProvider;
NSLog(@"carrierName %@",_carrier.carrierName);
NSLog(@"isoCountryCode %@",_carrier.isoCountryCode);
NSLog(@"mobileCountryCode %@",_carrier.mobileCountryCode);
NSLog(@"mobileNetworkCode %@",_carrier.mobileNetworkCode);
Run Code Online (Sandbox Code Playgroud)

试试这个方法,它的工作原理。

  • 每次我使用 iPod Touch 时它都会返回 null 可能是因为它不是基于 sim 的。但在 iPhone 中它返回 404。 (2认同)