iOS 16 CTCarrier deprecation
Asked Answered
R

2

20

For iOS 16, CTCarrier looks to have been deprecated.

https://developer.apple.com/documentation/coretelephony/ctcarrier

What will be the correct way, going forward, to receive information regarding carrier information such as MCC, MNC, and ISO country codes?

At my company, we use this information as data points to assist in scammer detection and a few other small but relatively important things, such as: limiting Phone Number logins from countries / carriers we do not support for pricing reasons.

I cant find any WWDC videos on the reason behind this deprecation or what any new classes may be that will support this information.

Rowland answered 8/8, 2022 at 19:50 Comment(5)
My expectation is that there is no replacement. This is the kind of functionality that Apple has a history of removing. I would open a DTS and ask Apple directly. Note that deprecated functions often continue to exist for a long time (though I would guess these were removed to prevent fingerprinting, so they may go away more quickly). Explaining to Apple your use case and exactly how you're using this information and how it helps your customers can sometimes lead to new APIs to support those use cases, and sometimes slows the removal of the API (though it may still be deprecated)Valenza
Interestingly, CTTelephonyNetworkInfo and serviceSubscriberCellularProviders are both not deprecated. serviceSubscriberCellularProviders returns CTCarrier developer.apple.com/documentation/coretelephony/…Fuller
serviceSubscriberCellularProviders returns a carrier regardless of if the SIM is inserted or not =(Kale
@RobNapier everything i opened with Apple via feedback, etc back then, they ultimately closedRowland
@Fuller it's marked deprecated now, must have been a mistake in documentation back then.Rowland
H
1

They will deprecate that in a later iOS version. In iOS 16.4 they return a static string for CTCarrier.isoCountryCode. We detected that via bug reports in our apps :-(

We will replace this with the following information from Locale.current.regionCode due to our assumption that users usually keep the device region of their home country and so have the same ISO country code of the SIM card. I know that is not always correct but it is the closest that we can get now. We then use the regionCode (e.g. en_US) to get the phone numbers ISO country code (e.g. +1) from a big enum which maps all countries to their phone number country code.

You can lookup relevant code here. The big JSON of countries which we use can be found here

Heptachord answered 3/5, 2023 at 8:33 Comment(2)
this doesn't get the MCC or MNC value, not to mention that is only the locale of their device, not of the carrier.Rowland
I updated my post to explain it a bit more in detail as well as to provide additional linksHeptachord
R
0

If you want to find the user's country, you can use the time. The TimeZone is always right for example in swift:

let identifier = TimeZone.current.identifier
print(identifier) //return => Asia/Tehran
Rosinarosinante answered 22/7, 2023 at 10:37 Comment(1)
this doesn't really work for all use cases. For example, if the user is a US based carrier and travels to a different country, and their timezone changesRowland

© 2022 - 2024 — McMap. All rights reserved.