I need to display the phone number format as a placeholder in a UITextField . Please let me know how I can do this.
To select a country, I use the library below, and it provides me with the country flag and country code for the selected country.
https://github.com/NikKovIos/NKVPhonePicker
After choosing a country, I need to display the phone number format for the selected country, and when sending this phone number I must confirm the phone number.
I also found that a third-party ( PhoneNumberKit ), which is inspired by google libphonenumber, but it is designed to be validated, does not provide the expected phone number format by country code. Below is the link.
https://github.com/marmelroy/PhoneNumberKit
thank
Update 1:
Tried this and got a Common Parser Error
let phoneNumberKit = PhoneNumberKit()
do {
let phoneNumber = try phoneNumberKit.parse("+921230123456")
}
catch {
print("Generic parser error")
}
Update 2:
Updated code still getting exception
let phoneNumberKit = PhoneNumberKit()
do {
let phoneNumber = try phoneNumberKit.parse("1230123456", withRegion: "FR", ignoreType: false)
let formatedNumber = phoneNumberKit.format(phoneNumber, toType: .international)
print(formatedNumber)
}
catch {
print("Generic parser error")
}
source
share