natintosh / intl_phone_number_input

MIT License
164 stars 496 forks source link

Problem: The number input field on IOS add also the country code #368

Open burekas7 opened 1 year ago

burekas7 commented 1 year ago

For example: Number is : 9295522887 initialValue: PhoneNumber(phoneNumber: "9295522887", isoCode: "US");

On Android: 1+ | (929) 552-2887

On IOS: 1+ | 1+ (929) 552-2887

Why there is a difference between them? Is it a known problem?

emillenard commented 1 year ago

I have the same problem. On getRegionInfoFromPhoneNumber has flutter: PlatformException(1, The country code is invalid., null, null) on iOS. On Android works fine.

joshuamoreno1 commented 1 year ago

I have both problems

tujii commented 1 year ago

Having the same issue :(

alabbasiDev commented 1 year ago

Having the same issue too

celiamaurewide commented 1 year ago

Having the same issue

DanielBerrioB commented 1 year ago

Having the same issue

zynhrus commented 1 year ago

Having the same issue

Any update?

BenSalemOumaima commented 1 year ago

I have the same issue with the latest version

emillenard commented 1 year ago

Nobody seems to care about this problem.

bynalab commented 1 year ago

@emillenard Sorry, I'll look into the issue today and see if I can get @natintosh to push some fixes out on this and other issues. Meanwhile, fixes PRs will be welcomed if anyone can help with fixing some of the issues created.

emillenard commented 1 year ago

@bynalab thanks, i found the problem, is in phone_number.dart the regionInfo.regionPrefix is the same with regionInfo.isoCode on iOS.

ydpatel1 commented 1 year ago

@bynalab thanks, i found the problem, is in phone_number.dart the regionInfo.regionPrefix is the same with regionInfo.isoCode on iOS.

Do you have any solution?

emillenard commented 1 year ago

The quiq fix for me was to change in library:

Changes in: input_widget.dart line 184 From: "String phoneNumber = await PhoneNumber.getParsableNumber(widget.initialValue!);" To: "String phoneNumber = widget.initialValue!.parseNumber();"

Changes in: SwiftLibphonenumberPlugin.swift line 81 From: "let countryCode: String? = phoneNumberKit.mainCountry(forCode: p.countryCode)" To: "let countryCode = "+" + String(p.countryCode)" line 77: From: "let p: PhoneNumber = try phoneNumberKit.parse(phoneNumber, withRegion: isoCode.uppercased(), ignoreType: true)" To:" let p: PhoneNumber = try phoneNumberKit.parse(phoneNumber)"

hrishikeshpujari1902 commented 1 year ago

@emillenard SwiftLibphonenumberPlugin.swift where is this file located

tigrenok00 commented 1 year ago

@emillenard @hrishikeshpujari1902 How to apply the fix the the swift file? Where is it? We need urgent fix in production. Is there a previous version which works fine?

tigrenok00 commented 1 year ago

@natintosh @bynalab Is there a workaround to be had? Will appreciate a fix for this ASAP!

emillenard commented 1 year ago

@emillenard @hrishikeshpujari1902 How to apply the fix the the swift file? Where is it? We need urgent fix in production. Is there a previous version which works fine? @hrishikeshpujari1902

hi, is not the best approach, but for quick fix to production until will be ok in library i changed the file from Pods , you will find the SwiftLibphonenumberPlugin.swift in Xcode on Pods/PhonKitNumber folder , change it and then compile the version.

hrishikeshpujari1902 commented 1 year ago

@tigrenok00 Do these changes in the local pub cache as a temporary fix. It will not format the number like added spaces in between but it wont add the extra country code as well. Changes in: input_widget.dart line 184 From: "String phoneNumber = await PhoneNumber.getParsableNumber(widget.initialValue!);" To: "String phoneNumber = widget.initialValue!.parseNumber();"

EUGinsane commented 1 year ago

I got same errors as above. can someone explain why this happens? Because I did not upgrade the package, still in version 0.7.0+2 since the first day, and now it suddenly breaks. Thanks

amirbahrawy commented 1 year ago

@emillenard @hrishikeshpujari1902 How to apply the fix the the swift file? Where is it? We need urgent fix in production. Is there a previous version which works fine? @hrishikeshpujari1902

hi, is not the best approach, but for quick fix to production until will be ok in library i changed the file from Pods , you will find the SwiftLibphonenumberPlugin.swift in Xcode on Pods/PhonKitNumber folder , change it and then compile the version.

can you explain clearly what you did exactly ?

honzasima commented 1 year ago

For fix use older version dependency

dependency_overrides: libphonenumber_plugin: 0.2.3

danysz commented 1 year ago

+1

ovchars2 commented 1 year ago

For fix use older version dependency

dependency_overrides: libphonenumber_plugin: 0.2.3

This worked for our project, thank you

Flutter 2.8.1 intl_phone_number_input 0.7.0+2 libphonenumber_plugin 0.2.3 (downgraded from 0.2.5)

sangmoonhwang commented 1 year ago

For fix use older version dependency

dependency_overrides: libphonenumber_plugin: 0.2.3

This does not sounds like a long-term fix since we would be stuck with the old dependency and its transitive dependencies. Is there a better way to solve this issue or should we just wait for the next libphonenumber_plugin version?