使用CoreTelephony獲取運營商信息的過程如下:
func actionTestCarrier() {
var info: CTTelephonyNetworkInfo = CTTelephonyNetworkInfo()
print(info)
var carrier: CTCarrier = info.subscriberCellularProvider!
print(carrier)
print(info.currentRadioAccessTechnology!)
print(carrier.carrierName!)
print(carrier.mobileCountryCode!)
print(carrier.mobileNetworkCode!)
}
結果如下:
CTCarrier (0x12de2dc10) {
Carrier name: [中國移動]
Mobile Country Code: [460]
Mobile Network Code:[00]
ISO Country Code:[cn]
Allows VOIP? [YES]
}
CTRadioAccessTechnologyLTE
中國移動
460
00
運營商對應的networkCode為: