For example, you want to format international number.
1) Start B4I, create a new "Default" project. Set your bundle id and add to Project Attributes
#CertificateFile : your.cer ' <- Change
#ProvisionFile : your.mobileprovision ' <- Change
#AdditionalLib: libPhoneNumberiOS.framework.swift.3
2) Add following code to the bottom of the module
#if OBJC
#import <libPhoneNumberiOS/libPhoneNumberiOS.h>
- (NSString*) PhoneInternational: (NSString*) Number : (NSString*) DefaultRegion
{
NBPhoneNumberUtil *phoneUtil = [[NBPhoneNumberUtil alloc] init];
NSError *anError = nil;
NSString *answer = nil;
NBPhoneNumber *myNumber = [phoneUtil parse: Number defaultRegion: DefaultRegion error: &anError];
if (anError == nil) { answer = [phoneUtil format: myNumber numberFormat: NBEPhoneNumberFormatINTERNATIONAL error: &anError]; };
if (anError != nil) { answer = [anError localizedDescription]; };
return answer;
}
#End If
3) Add call to Application_Start subroutine
Dim nme As NativeObject = Me
Log (nme.RunMethod ("PhoneInternational::", Array ("+5491133954455", "")).AsString)
Run on iPhone. The result (in Log) will be
+54 9 11 3395-4455
You can specify national number also (without + and country code), but in this case you must specify a region:
Log (nme.RunMethod ("PhoneInternational::", Array ("0111533954455", "AR")).AsString)
If you want output as national number, replace NBEPhoneNumberFormatINTERNATIONAL to NBEPhoneNumberFormatNATIONAL.
In this case output will be
011 15-3395-4455