ios - CoreTelephony - 处于飞行模式时的运营商名称

标签 ios swift core-telephony

我有以下代码来获取我的服务提供商的运营商名称:

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#*服务时,如果处于飞行模式,则不会显示所有信息。

最佳答案

@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/

相关文章:

ios - 立即切换输入类型时如何在iOS 11中获取表情符号键盘的高度?

ios - 使用小写字母和数组过滤搜索文本的内容

swift - 如何连接两个注释点?

iphone - 如何从 iPhone 上的来电中获取来电者的电话号码

ios - 在 iOS 8.3 中获取 CellID、MCC、MNC、LAC、信号强度、质量和网络

ios - CFUUID数组?

ios - 具有捕捉和缩放功能的 ScrollView

objective-c - .plist 文件写入失败!这段代码有什么问题?

ios - 在 Swift 中从 Uibezierpath 数组创建一个 UIImage

ios - ios 8.3 中的信号强度