好的,我有一个应用程序需要读取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卡]: 运营商名称:Free, MCC:208, MNC:15, ISO国家代码:fr, CTRadioAccessTechnology:WCDMA。
但是实际上,我得到了[eSIM]: 运营商名称:Swisscom, MCC:228, MNC:01, ISO国家代码:ch, CTRadioAccessTechnology:LTE。
编辑: 如果您知道如何同时读取两者的信息,那对我也没问题,我的目标是检测用户是否使用Free Mobile [208 15]的SIM卡。