I am creating an app where i need to show user some details from the network provider in the iPhone such as ICCID, or phone number etc
This is my current code
let networkInfo = CTTelephonyNetworkInfo()
if let carrier = networkInfo.serviceSubscriberCellularProviders?.values.first {
print("Carrier Name: (carrier.carrierName ?? "Unknown")")
print("Mobile Country Code: (carrier.mobileCountryCode ?? "Unknown")")
print("Mobile Network Code: (carrier.mobileNetworkCode ?? "Unknown")")
print("ISO Country Code: (carrier.isoCountryCode ?? "Unknown")")
print("Allows VOIP: (carrier.allowsVOIP)")
} else {
print("No carrier information available")
}
and receiving default values
Carrier Name: --
Mobile Country Code: 65535
Mobile Network Code: 65535
ISO Country Code: --
Allows VOIP: true
New contributor
Mohammad Ali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.