使用 CoreTelephony 获取运营商名称仅返回“Carrier”
我尝试使用此代码获取运营商名称(使用 CoreTelephony):
CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [netinfo subscriberCellularProvider];
NSLog(@"Carrier Name: %@", [carrier carrierName]);
它返回“Carrier”。如果我进入 iPhone 设置,我的运营商名称是正确的。我手机上的iOS版本是v4.2.1。
我做错了什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你真的得到字符串“Carrier”还是字符串为空?文档说:
打赌它在模拟器中也是空的。
无论如何,您应该检查mobileNetworkCode,因为名称很少是正确的(至少在欧洲,运营商经常更改名称)。
Do you really get string "Carrier" or is the string empty? Documentation says:
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).
通过此,您可以获得移动网络代码、移动国家代码。从这些值
您可以指定这个 sim 名称。
您可以为此创建Web服务来指定该参数所属的网络运营商名称。
这些参数可以从此 wikipedia 中唯一标识。
例如,我的国家/地区代码是“410”,我的运营商网络是“06”,它可以正确识别我的运营商名称。
我也遇到了同样的问题,现在解决了
by this, you can get mobile Network code, mobile country code . from these values
you can specify which sim name is this.
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