【发布时间】:2019-04-02 11:39:49
【问题描述】:
我有以下代码来获取我的服务提供商的运营商名称:
let ctTelePhony = CTTelephonyNetworkInfo()
func cellPhoneServices() -> String {
let serviceProvider = ctTelePhony.subscriberCellularProvider
if let carrierName = serviceProvider?.carrierName {
globalCarrierName = carrierName
return carrierName}
else {
globalCarrierName = "Nil"
return "Nil"}
}
根据文档,subscriberCellularProvider 已被弃用并替换为 serviceSubscriberCellularProviders ,但是在使用该服务时,它返回 nil。
主要问题是:当我使用上面的代码时,我得到了承运人名称,但是当我切换到飞行模式时,我仍然得到我的承运人名称。
运营商信息是否存储在手机本地?使用*3001#12345#*服务时,飞行模式下不显示所有信息。
【问题讨论】:
标签: ios swift core-telephony