问题
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