Getting wrong carrier name in IOS

寵の児 提交于 2019-12-18 16:52:08

问题


I am working on an IOS application.My requirement is to get the mobile carrier name.I used the following code.

In .h

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

In .m

CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [netinfo subscriberCellularProvider];
NSLog(@"Carrier Name: %@", [carrier carrierName]);


Here in Log its printing "Carrier"

I googled and found this link.But as per its answer my device is still not in airplane mode and sim card exists inside.If any one worked on it,please help me.Its killing my time.Thanks in advance


回答1:


Try with mobile country code & mobile network code like this:

NSLog(@"Mobile Country Code: %@", [carrier mobileCountryCode]);
NSLog(@"Mobile Network Code: %@", [carrier mobileNetworkCode]);

Then you can use this list to match your results.

http://en.wikipedia.org/wiki/Mobile_country_code

Good luck.



来源:https://stackoverflow.com/questions/21186307/getting-wrong-carrier-name-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!