I am trying to get the user carrier name using this code:
CTTelephonyNetworkInfo* info = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier* carrier = info.subscriberCellularProvider;
NSString *mobileCountryCode = carrier.mobileCountryCode;
NSString *carrierName = carrier.carrierName;
NSString *isoCountryCode = carrier.isoCountryCode;
NSString *mobileNetworkCode = carrier.mobileNetworkCode;
But when I try to log, the result is like this:
2023-05-22 16:47:39.831078+0700 MotionTrade[7686:985518] carrier name = --
2023-05-22 16:47:39.831260+0700 MotionTrade[7686:985518] mobileCountryCode = 65535
2023-05-22 16:47:39.831342+0700 MotionTrade[7686:985518] mobileNetworkCode = 65535
Basically I've tried every stack overflow answer but I still get the same results,
I debug this on my iPhone and not using WiFi, and I only use physical sim, not e-sim.
Can anyone tell me why I keep getting that "--"?
And after I browse a bit, country code "65535" is this could be an indication of removed SIM card, or in general inability to make a call at the moment.
Can anyone help me? Why is this happening and how to get a proper cellular provider name?
I even try to do it on my new blank project with this code:
override func viewDidLoad() {
super.viewDidLoad()
let networkInfo = CTTelephonyNetworkInfo()
let carrierName = networkInfo.serviceSubscriberCellularProviders
dump(carrierName)
}
but I still get the same result in my log:
Optional(["0000000100000001": CTCarrier (0x281275d10) {
Carrier name: [--]
Mobile Country Code: [65535]
Mobile Network Code:[65535]
ISO Country Code:[--]
Allows VOIP? [YES]
}
, "0000000100000002": CTCarrier (0x28126ca20) {
Carrier name: [--]
Mobile Country Code: [65535]
Mobile Network Code:[65535]
ISO Country Code:[--]
Allows VOIP? [YES]
}
] )
Please help me. Why do I keep getting "--" and 65535? Is there any way to get carrier name? Or is getting carrier name in iOS 16 not possible?
CTCarrier is deprecated with no replacement in iOS 16. This information is no longer available, and I would not expect it to become available again. I'm somewhat surprised it was ever available. (Apple generally avoids making information available that can be used to fingerprint the user without a very clear use case, and usually an entitlement.)
You can find the announcement about returning static values in the iOS 16.4 Release Notes.