我没有从iPhone中找到只在iphone中使用eSIM的移动国家代码,即12.1OS。
对于“物理sim”,下面的代码运行良好,但只安装eSIM时会遇到问题
CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [netInfo subscriberCellularProvider];
NSString* mcc = [carrier mobileCountryCode];发布于 2018-12-28 10:13:16
在eSIM中,您可以通过
if #available(iOS 12.0, *) {
if let countryCode = CTTelephonyNetworkInfo().serviceSubscriberCellularProviders?.values.first(where: { $0.isoCountryCode != nil }) {
print("Country Code : \(countryCode)")
}
}注意:来自iOS 12+,而不是subscriberCellularProvider,使用serviceSubscriberCellularProviders。
https://stackoverflow.com/questions/53761209
复制相似问题