I am using libPhoneNumber-iOS (https://github.com/iziz/libPhoneNumber-iOS) to parse international phone numbers, and I am having a bit of trouble differentiating between different countries with the same country code (e.g. USA and Canada both use +1). Does anyone know if this library does this?
Here is the code I'm using to retrieve the country code (region code i.e. "US"):
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"
}
This code returns "US" for the country code, even though it is a Canadian number. Does anyone know what I can do to get the accurate country using this library?