libPhoneNumber-iOS
libPhoneNumber-iOS copied to clipboard
v1.0.2 not parsing phone number correctly
Hi,
I've been running into issues where phonenumbers aren't correctly parsed. It works on v0.9.15 but not on v1.0.2. I'm using this method:
+ (NSString *)getCountryFromCallee:(NSString *)locale PhoneNumber:(NSString *)phoneNumber {
NBPhoneNumberUtil *phoneUtil = [NBPhoneNumberUtil new];
NSError *error = nil;
NBPhoneNumber *parsedNumber = [phoneUtil parse:phoneNumber defaultRegion:locale error:&error];
if (error == nil && parsedNumber != nil) {
return [phoneUtil getRegionCodeForNumber:parsedNumber];
} else {
DLog(@"Error parsing phone number: %@, Locale: %@ with error: %@ and parsedNumber: %@", phoneNumber, locale, error, parsedNumber);
return @"";
}
}
When parsing with a phonenumber like +31612345678 it returns the following error:
Error Domain=NOT_A_NUMBER Code=0 "Error Domain=NOT_A_NUMBER Code=0 "NOT_A_NUMBER:" UserInfo={NSLocalizedDescription=NOT_A_NUMBER:}" UserInfo={NSLocalizedDescription=Error Domain=NOT_A_NUMBER Code=0 "NOT_A_NUMBER:" UserInfo={NSLocalizedDescription=NOT_A_NUMBER:}}
However this works fine when using the online libphonenumber for testing.
Check #324, you need to use the singleton instance.