Checking for US number like 14155552671 isValidNumber returned is false
Tested on the link for this number(14155552671), both isValid and isPossible number returns true. But the ios library for isValidNumber returns false.
I can confirm this - for US numbers, libPhoneNumber-iOS says they are invalid although the number is valid according to the linked website. I tried with +115417543010.
OK I will check it.
With https://github.com/iziz/libPhoneNumber-iOS/pull/175, the following code appears to work:
NSError *error = nil; NBPhoneNumber *phoneNumberUS = [phoneUtil parse:@"14155552671" defaultRegion:@"US" error:&error]; NSLog(@"- isValidNumber [%@]", [phoneUtil isValidNumber:phoneNumberUS] ? @"YES" : @"NO"); NSLog(@"- isPossibleNumber [%@]", [phoneUtil isPossibleNumber:phoneNumberUS error:&error] ? @"YES" : @"NO"); NSLog(@"- getRegionCodeForNumber [%@]", [phoneUtil getRegionCodeForNumber:phoneNumberUS]);
2017-03-19 21:32:32.644 MetadataGenerator[25153:3448544] - isValidNumber [YES] 2017-03-19 21:32:34.856 MetadataGenerator[25153:3448544] - isPossibleNumber [YES] 2017-03-19 21:32:36.578 MetadataGenerator[25153:3448544] - getRegionCodeForNumber [US]
Thanks a lot guys, everything running smoothly now!
@thailow what did you end up doing to solve this? We are running into the same issue now.
Turns out Puerto Rico's area code (787) is not a valid prefix for the US region...