Closed mithleshgomotive closed 4 months ago
Hey @mithleshgomotive
The main reason why it's working on version 3.3.4 is because it's using a deprecated way to get the default region for iOS 16 and 17 (maybe iOS 15 too), which means that it will always fallback to US
as default region.
The recent releases relies on system's region if available. The region is needed in order to parse a phone number that doesn't contain the international code.
If you always have the international code, it will work independently of the region set, if the international code is not available, the library will use whatever is available to try to parse the phone number.
So, with that in mind, you need to update your unit tests to pass a region or the full phone number.
I hope it helps.
Thanks for responding & clarifying @bguidolim
New Issue Checklist
Steps to reproduce
Basically I was using
PhoneNumberKit
version3.3.4
and with this I also had unit-test written. Things were working fine. Few weeks back, I bumped the version of PhoneNumberKit library to3.7.9
(or now3.7.10
), the same UT was not working for non-US regions.UT's working or not working, is fine anyway. But I just noticed the region got changed as I'm working from India. The colleague working from US, for them this change doesn't matter and UT kept on working.
The UT was failing for India, Poland basically non-US region.
For one of my colleague in Poland region, the other set of UT started to fail (being region specific).
I debugged and found that since we are not passing explicitly defaultRegion code to PhoneNumberKit, it's causing to fail because it's taking
user's current region - based on the iPhone's carrier and if not available, the device region.
Screenshot for reference.
3.7.10
3.3.4
The above one is not expected IMO. I am raising this as an issue because the set of UT was working earlier and now with version bump it started to fail.
To fix this issue:
region: String
).PhoneNumberKit.defaultRegionCode()
Still I wanted to call this out because change in behaviour. Can you please check this and let us know why there is behavioural change here?
Expected result
3.3.4
and failing in3.7.9
/3.7.10
(India [IN
] region)Actual result
Environment
3.3.4