问题描述
我尝试使用以下代码获取运营商名称(使用CoreTelephony):
I tried getting carrier name with this code (using CoreTelephony):
CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [netinfo subscriberCellularProvider];
NSLog(@"Carrier Name: %@", [carrier carrierName]);
它返回载波".如果我转到iPhone设置,那里的运营商名称是正确的.我在手机上的iOS是v4.2.1.
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.
我在做什么错了?
推荐答案
您真的收到字符串"Carrier"还是该字符串为空?文档说:
Do you really get string "Carrier" or is the string empty? Documentation says:
设备处于飞行模式.设备中没有SIM卡. 该设备不在蜂窝服务范围内.
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.
无论如何,您应该检查 mobileNetworkCode ,因为名称很少正确(至少在欧洲,运营商来来往往地更改名称).
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).
这篇关于通过CoreTelephony获取运营商名称只会返回"Carrier".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!