Devices that have iOS 16.6.1 and beyond throw an invalid country code error.
This code works for iOS versions prior to 16.6.1. Any iOS version after 16.6.1 throws an invalid country code error even though it is a valid country code. When this code is run on devices with iOS 16.3.1 it does not throw an error.
I haven't been able to test anything between iOS 16.3.1 and 16.6.1, but I do believe the break happened with 16.6.1.
let phoneNumberUtility = NBPhoneNumberUtil()
do {
let nbPhone : NBPhoneNumber = try phoneNumberUtility.parse(withPhoneCarrierRegion: phone)
let phoneNumber : NSNumber = nbPhone.nationalNumber
let countryCode: NSNumber = nbPhone.countryCode
print(phoneNumber,countryCode)
phoneNumbers.append(("+(countryCode)") + " " + ("(phoneNumber)"))
} catch let error as NSError {
print("Phone Number Invalid! Error: (error.localizedDescription)")
}
Error Print Statement:
Phone Number Invalid! Error: Error Domain=INVALID_COUNTRY_CODE Code=0 "INVALID_COUNTRY_CODE:--" UserInfo={NSLocalizedDescription=INVALID_COUNTRY_CODE:--}
Devices that have iOS 16.6.1 and beyond throw an invalid country code error.
This code works for iOS versions prior to 16.6.1. Any iOS version after 16.6.1 throws an invalid country code error even though it is a valid country code. When this code is run on devices with iOS 16.3.1 it does not throw an error.
I haven't been able to test anything between iOS 16.3.1 and 16.6.1, but I do believe the break happened with 16.6.1.
let phoneNumberUtility = NBPhoneNumberUtil() do { let nbPhone : NBPhoneNumber = try phoneNumberUtility.parse(withPhoneCarrierRegion: phone) let phoneNumber : NSNumber = nbPhone.nationalNumber let countryCode: NSNumber = nbPhone.countryCode print(phoneNumber,countryCode) phoneNumbers.append(("+(countryCode)") + " " + ("(phoneNumber)")) } catch let error as NSError { print("Phone Number Invalid! Error: (error.localizedDescription)") }
Error Print Statement:
Phone Number Invalid! Error: Error Domain=INVALID_COUNTRY_CODE Code=0 "INVALID_COUNTRY_CODE:--" UserInfo={NSLocalizedDescription=INVALID_COUNTRY_CODE:--}