mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Stop using CTCarrier for country code detection due to it's deprecation
This commit is contained in:
parent
939b29770a
commit
5d967279b9
@ -1296,18 +1296,9 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
|
||||
}
|
||||
|
||||
public static func defaultCountryCode() -> Int32 {
|
||||
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 countryCode: Int32 = 1
|
||||
|
||||
if let countryId = countryId {
|
||||
let normalizedId = countryId.uppercased()
|
||||
for (code, idAndName) in countryCodeToIdAndName {
|
||||
|
@ -5,7 +5,6 @@ import Display
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import CoreTelephony
|
||||
import TelegramPresentationData
|
||||
import AccountContext
|
||||
import AlertUI
|
||||
@ -382,17 +381,9 @@ extension SecureIdPlaintextFormInnerState {
|
||||
init(type: SecureIdPlaintextFormType, immediatelyAvailableValue: SecureIdValue?) {
|
||||
switch type {
|
||||
case .phone:
|
||||
var countryId: String? = nil
|
||||
if let carrier = CTTelephonyNetworkInfo().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 {
|
||||
|
@ -162,8 +162,26 @@ public func ChangePhoneNumberController(context: AccountContext) -> ViewControll
|
||||
}
|
||||
|
||||
Queue.mainQueue().justDispatch {
|
||||
controller.updateData(countryCode: AuthorizationSequenceController.defaultCountryCode(), countryName: nil, number: "")
|
||||
controller.updateCountryCode()
|
||||
let _ = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: context.account.peerId))
|
||||
|> deliverOnMainQueue).start(next: { accountPeer in
|
||||
guard let accountPeer, case let .user(user) = accountPeer else {
|
||||
return
|
||||
}
|
||||
|
||||
let initialCountryCode: Int32
|
||||
if let phone = user.phone {
|
||||
if let (_, countryCode) = lookupCountryIdByNumber(phone, configuration: context.currentCountriesConfiguration.with { $0 }), let codeValue = Int32(countryCode.code) {
|
||||
initialCountryCode = codeValue
|
||||
} else {
|
||||
initialCountryCode = AuthorizationSequenceController.defaultCountryCode()
|
||||
}
|
||||
} else {
|
||||
initialCountryCode = AuthorizationSequenceController.defaultCountryCode()
|
||||
}
|
||||
controller.updateData(countryCode: initialCountryCode, countryName: nil, number: "")
|
||||
controller.updateCountryCode()
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
return controller
|
||||
|
@ -3,7 +3,6 @@ import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import TelegramCore
|
||||
import CoreTelephony
|
||||
import TelegramPresentationData
|
||||
import PhoneInputNode
|
||||
import CountrySelectionUI
|
||||
@ -211,18 +210,9 @@ final class ChangePhoneNumberControllerNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user