-
NBPhoneNumber, NBNumberFormat, NBPhoneNumberDesc, NBPhoneMetaData (Metadata classes)
-
NBPhoneNumberUtil (from phonenumberutil.js)
Use CocoaPods
- NBPhoneNumberUtil.h, .m
- NBNumberFormat.h, .m
- NBPhoneNumber.h, .m
- NBPhoneNumberDesc.h, .m
- NBPhoneNumberDefines.h
- NBPhoneNumberMetadata.h, .m
- NBPhoneNumberMetadataForTesting.h, .m
- Add "NBPhoneNumberMetadata.plist" and "NBPhoneNumberMetadataForTesting.plist" to bundle resources
See sample test code from "libPhoneNumber-iOS / libPhoneNumberTests / libPhoneNumberTests.m"
NBPhoneNumberUtil *phoneUtil = [NBPhoneNumberUtil sharedInstance];
NSError *aError = nil;
NBPhoneNumber *myNumber = [phoneUtil parse:@"6766077303" defaultRegion:@"AT" error:&aError];
if (aError == nil)
{
NSLog(@"isValidPhoneNumber ? [%@]", [phoneUtil isValidNumber:myNumber] ? @"YES":@"NO");
NSLog(@"E164 : %@", [phoneUtil format:myNumber numberFormat:NBEPhoneNumberFormatE164]);
NSLog(@"INTERNATIONAL : %@", [phoneUtil format:myNumber numberFormat:NBEPhoneNumberFormatINTERNATIONAL]);
NSLog(@"NATIONAL : %@", [phoneUtil format:myNumber numberFormat:NBEPhoneNumberFormatNATIONAL]);
NSLog(@"RFC3966 : %@", [phoneUtil format:myNumber numberFormat:NBEPhoneNumberFormatRFC3966]);
}
else
{
NSLog(@"Error : %@", [aError localizedDescription]);
}
NSLog (@"extractCountryCode [%ld]", [phoneUtil extractCountryCode:@"823213123123" nationalNumber:nil]);
NSString *res = nil;
UInt32 dRes = [phoneUtil extractCountryCode:@"823213123123" nationalNumber:&res];
NSLog (@"extractCountryCode [%lu] [%@]", dRes, res);
Visit http://code.google.com/p/libphonenumber/ for more information
svn checkout http://libphonenumber.googlecode.com/svn/trunk/ libphonenumber-read-only
Output - "PhoneNumberMetaData.json" and "PhoneNumberMetaDataForTesting.json"
Output - "NBPhoneNumberMetadata.plist" and "NBPhoneNumberMetadataForTesting.plist"
Step4. Update exists "NBPhoneNumberMetadata.plist" and "NBPhoneNumberMetadataForTesting.plist" files
- Remain javascript libPhonenumber code logic (and comments etc) as possible for maintenance with *.js