You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
getFullNumberWithPlus() includes national trunk prefixes #149
The CountryCodePicker.getFullNumberWithPlus() method appends a '+' to the countryCode and carrierNumber from user input.
When a user is inputting a phone number including the national trunk prefix, for instance for French (+33) numbers the value '0610101010', the method getFullNumberWithPlus() returns +330610101010 instead of +33610101010.
The first '0' directly after the country code is only used for national calls. International calls with '+33' should remove it.
Hence, the getFullNumberWithPlus() method can return invalid phone numbers.
Here's an example of I expected the getFullNumberWithPlus() to work, using the embedded libphonenumber-android lib:
privatefungetExpectedFullNumberWithPlus(context:Context): String {
val phoneUtil =PhoneNumberUtil.createInstance(context)
try {
val countryCode = countryCodePicker.selectedCountryCode
val defaultRegion = countryCodePicker.selectedCountryNameCode
var numberToParse = countryCodePicker.fullNumber
if (numberToParse.startsWith(countryCode)) {
numberToParse = numberToParse.substring(countryCode.length)
}
val phoneNumber = phoneUtil.parse(numberToParse, defaultRegion)
return"+${phoneNumber.countryCode}${phoneNumber.nationalNumber}"
} catch (e:NumberFormatException) {
Timber.e(e, "Error parsing number")
}
return countryCodePicker.fullNumberWithPlus
}
Activity
hbb20 commentedon Jan 30, 2018
Thank you for the suggestion. This has been fixed in version 2.1.4.