Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem getting correct country code #367

Open
varali opened this issue Apr 27, 2022 · 0 comments
Open

Problem getting correct country code #367

varali opened this issue Apr 27, 2022 · 0 comments

Comments

@varali
Copy link

varali commented Apr 27, 2022

I am having an issue getting the correct country back from getRegionCode(forCountryCode:). For the following code, I am getting "US" back when I should be getting "CA". Can someone tell me if there is an issue with the library or if my code is incorrect?

let fullPhoneNumber = "+15065552222"

guard let phoneUtil = NBPhoneNumberUtil.sharedInstance() else {
    return "error"
}

do {
    let phoneNumber = try phoneUtil.parse(fullPhoneNumber, defaultRegion: "ZZ")

    return phoneUtil.getRegionCode(forCountryCode: phoneNumber.countryCode)
    
} catch {
    return "error"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant