Stop using CTCarrier for country code detection due to it's deprecation

This commit is contained in:
Ilya Laktyushin
2024-02-19 19:17:51 -04:00
parent 939b29770a
commit 5d967279b9
5 changed files with 27 additions and 47 deletions

View File

@@ -10,7 +10,6 @@ import ItemListUI
import PresentationDataUtils
import PhoneInputNode
import CountrySelectionUI
import CoreTelephony
private func generateCountryButtonBackground(color: UIColor, strokeColor: UIColor) -> UIImage? {
return generateImage(CGSize(width: 56, height: 44.0 + 6.0), rotatedContext: { size, context in
@@ -234,18 +233,9 @@ class DeleteAccountPhoneItemNode: ListViewItemNode, ItemListItemNode {
}
}
var countryId: String? = nil
let networkInfo = CTTelephonyNetworkInfo()
if let carrier = networkInfo.serviceSubscriberCellularProviders?.values.first {
countryId = carrier.isoCountryCode
}
if countryId == nil {
countryId = (Locale.current as NSLocale).object(forKey: .countryCode) as? String
}
let countryId = (Locale.current as NSLocale).object(forKey: .countryCode) as? String
var countryCodeAndId: (Int32, String) = (1, "US")
if let countryId = countryId {
let normalizedId = countryId.uppercased()
for (code, idAndName) in countryCodeToIdAndName {