查找正在使用的运营商信息,而不是SIM卡

时间:2015-02-08 16:14:32

标签: android ios core-telephony carrier

是否有可能获得有关当前使用的运营商的信息? CoreTelefony提供有关SIM运营商的信息。

我没有在互联网上发现任何关于这个话题的文章。由于用户在其他国家/地区移动时SIM卡也可以相同,我想查看手机正在使用的当前网络信息。

有机会达到这个结果吗?

我对iOS和Android代码感兴趣。

1 个答案:

答案 0 :(得分:1)

I ran into this problem a while back,我找到了一种适合我目的的方法。它不漂亮,不是未来的证据,也没有记录。但我目前在AppStore中有一个使用它的应用程序。

哦,它只在iOS 7.0 - 8.2上测试过!

所以是的,对于iOS我知道可以找到MMC and MNC,这样你就可以找到国家和提供商:

// This is the location of the operator symlink
static NSString * operatorPListSymLinkPath = @"/var/mobile/Library/Preferences/com.apple.operator.plist";

// Here we get the path where the symlink points to
NSFileManager * fileManager = [NSFileManager defaultManager]
NSError * error;
NSString * operatorPListPath = [fileManager destinationOfSymbolicLinkAtPath:operatorPListSymLinkPath error:&error];

运营商路径包含一些数字,其中前3个是提供商的MCC(移动国家代码),之后的少数是MNC(移动网络代码)

我只想找到国家/地区(MCC),所以我使用了这个:

operatorPListPath = [operatorPListPath stringByTrimmingCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:@"1234567890"] invertedSet]];
NSString * countryMCC = [operatorPListPath substringToIndex:3];

您只需要一个MCC>国家字典和MNC>网络字典,以检查这些代码代表什么

虽然不能帮助你解决Android .. :)

相关问题