如何处理serviceSubscriberCellularProviders仅从物理SIM卡而非eSIM获取数据?

时间:2019-02-09 00:04:31

标签: swift core-telephony

好吧,所以我有一个需要从SIM卡读取数据的应用程序。更确切地说,我需要运营商名称,MCC,MNC,ISO国家(地区)代码和当前的无线访问技术(好吧,这不直接来自SIM卡,而是链接在一起的)。它可以在每部手机上完美运行,但经过测试后,我意识到我对装有eSIM的最新款iPhone遇到了麻烦。我不知道如何告诉我的应用读取物理SIM卡而不是eSIM的数据。

我试图在网上搜索一下,但是我什么都没发现……

let telephonyInfo: CTTelephonyNetworkInfo = CTTelephonyNetworkInfo()

carrierNetwork = telephonyInfo.serviceCurrentRadioAccessTechnology?.first?.value ?? "null"
carrierNetwork = carrierNetwork.replacingOccurrences(of: "CTRadioAccessTechnology", with: "", options: NSString.CompareOptions.literal, range: nil)

let carrier = telephonyInfo.serviceSubscriberCellularProviders?.first?.value // actually here originally I tried to use ?.values.first, but the result is the same

let countryCode = carrier?.mobileCountryCode ?? "null"
let mobileNetworkName = carrier?.mobileNetworkCode ?? "null"
let carrierName = carrier?.carrierName ?? "null"
let isoCountrycode = carrier?.isoCountryCode?.uppercased() ?? "null"

/* so the problem is that the values I get are the ones from the eSIM when it is set up. If it is not, then I get the values I want. Apparently, when the physical SIM card line is set as primary, it works. But I need that code to systematically use the physical SIM data. */

示例:

我希望[物理SIM卡]: 运营商名称:免费, 我的客户中心:208, 跨国公司:15 ISO国家/地区代码:fr, CTRadioAccessTechnology:WCDMA。

但是,我得到了[eSIM]: 运营商名称:Swisscom, 我的客户中心:228, 跨国公司:01, ISO国家/地区代码:ch, CTRadioAccessTechnology:LTE。

编辑:如果您知道我能同时阅读两者,那对我也很好,我的目标是检测用户是否使用了Free Mobile [208 15] SIM卡。

0 个答案:

没有答案