intl_phone_number_input icon indicating copy to clipboard operation
intl_phone_number_input copied to clipboard

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

Open burekas7 opened this issue 2 years ago • 24 comments

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?

burekas7 avatar Jan 19 '23 19:01 burekas7

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

emillenard avatar Jan 26 '23 12:01 emillenard

I have both problems

joshuamoreno1 avatar Feb 02 '23 04:02 joshuamoreno1

Having the same issue :(

tujii avatar Feb 07 '23 20:02 tujii

Having the same issue too

alabbasiDev avatar Feb 09 '23 18:02 alabbasiDev

Having the same issue

celiamaurewide avatar Feb 10 '23 11:02 celiamaurewide

Having the same issue

DanielBerrioB avatar Feb 10 '23 13:02 DanielBerrioB

Having the same issue

Any update?

zynhrus avatar Feb 13 '23 04:02 zynhrus

I have the same issue with the latest version

BenSalemOumaima avatar Feb 15 '23 10:02 BenSalemOumaima

Nobody seems to care about this problem.

emillenard avatar Feb 15 '23 11:02 emillenard

@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.

bynalab avatar Feb 15 '23 12:02 bynalab

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

emillenard avatar Feb 15 '23 12:02 emillenard

@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?

ydpatel1 avatar Feb 15 '23 13:02 ydpatel1

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)"

emillenard avatar Feb 15 '23 15:02 emillenard

@emillenard SwiftLibphonenumberPlugin.swift where is this file located

hrishikeshpujari1902 avatar Feb 16 '23 12:02 hrishikeshpujari1902

@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 avatar Feb 19 '23 16:02 tigrenok00

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

tigrenok00 avatar Feb 19 '23 16:02 tigrenok00

@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.

emillenard avatar Feb 20 '23 06:02 emillenard

@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();"

hrishikeshpujari1902 avatar Feb 21 '23 06:02 hrishikeshpujari1902

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

EUGinsane avatar Mar 01 '23 09:03 EUGinsane

@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 ?

amirbahrawy avatar Mar 14 '23 09:03 amirbahrawy

For fix use older version dependency

dependency_overrides: libphonenumber_plugin: 0.2.3

honzasima avatar Mar 23 '23 08:03 honzasima

+1

danysz avatar Mar 26 '23 07:03 danysz

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)

ovchars2 avatar Mar 31 '23 18:03 ovchars2

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?

sangmoonhwang avatar Apr 30 '23 05:04 sangmoonhwang