我有以下代码来获取我的服务提供商的运营商名称:
let ctTelePhony = CTTelephonyNetworkInfo()
func cellPhoneServices() -> String {
let serviceProvider = ctTelePhony.subscriberCellularProvider
if let carrierName = serviceProvider?.carrierName {
globalCarrierName = carrierName
return carrierName}
else {
globalCarrierName = "Nil"
return "Nil"}
}
根据文档,subscriberCellular
Provider 已被弃用并被 serviceSubscriberCellularProviders
取代,但是在使用该服务时,它返回 nil。
主要问题是:当我使用上面的代码时,我得到了运营商名称,但是当我切换到飞行模式时,我仍然得到了我的运营商名称。
运营商信息是否存储在手机本地?使用*3001#12345#*
服务时,如果处于飞行模式,则不会显示所有信息。
最佳答案
@property(nonatomic, readonly, retain) NSString *carrierName;
如果我们为运营商配置设备,将设备置于飞行模式,即使 SIM 卡被移除,设备仍会返回运营商。运营商信息可能安全地保存在设备内的某个位置。
This string is provided by the carrier and formatted for presentation to the user. The value does not change if the user is roaming; it always represents the provider with whom the user has an account.
If you configure a device for a carrier and then remove the SIM card, this property retains the name of the carrier.
The value for this property is nil if the device was never configured for a carrier.
关于ios - CoreTelephony - 处于飞行模式时的运营商名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53047212/