开发者

Getting carrier's name with CoreTelephony returns just "Carrier"

I tried getting carrier name with this code (using CoreTelephony):

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

It returns "Carrier". If i go to iPhone settings my carrier's name is correct there.开发者_开发技巧 My iOS on the phone is v4.2.1.

What am i doing wrong?


Do you really get string "Carrier" or is the string empty? Documentation says:

The value for this property is nil if any of the following apply:

The device is in Airplane mode. There is no SIM card in the device. The device is outside of cellular service range.

Bet it's empty also in simulator.

Anyway, you should be checking mobileNetworkCode, since names are rarely correct (at least in Europe, where operators come and go changing their names quite often).


by this, you can get mobile Network code, mobile country code . from these values you can specify which sim name is this.

CTTelephonyNetworkInfo* info = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier* carrier = info.subscriberCellularProvider;
NSString *mobileCountryCode = carrier.mobileCountryCode;
NSString *carrierName = carrier.carrierName;
NSString *isoCountryCode = carrier.isoCountryCode;
NSString *mobileNetworkCode = carrier.mobileNetworkCode;

and you can make web service for this to specify which carrier name of the network, this parameter belongs to. these parameters can be uniquely identified from this wikipedia.

for example, my country code is "410", my carrier network is "06" and it correctly identifies my carrier name.

I was also stuck at the same issue and now solved

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜