iziz / libPhoneNumber-iOS

iOS port from libphonenumber (Google's phone number handling library)
Apache License 2.0
2.35k stars 459 forks source link

iOS 16.6.1 breaking change - Invalid Country Code Error #398

Open micahburnside opened 8 months ago

micahburnside commented 8 months ago

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:--}