iOS / CTCarrier on iOS 12
2019-08-09
Environments
- Swift 5.0
- Xcode 10
- Mojave
step
ViewController.swift
import CoreTelephony
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
textView.text = ""
let info: CTTelephonyNetworkInfo = CTTelephonyNetworkInfo()
for (service, carrier) in info.serviceSubscriberCellularProviders ?? [:] {
print("\(service), \(carrier)")
print(carrier.carrierName!)
print(carrier.mobileCountryCode!)
print(carrier.mobileNetworkCode!)
print(carrier.isoCountryCode!)
print(carrier.allowsVOIP)
textView.text.append("Service: \(service), Carrier: \(carrier.description)\n")
}
}