|
13 | 13 |
|
14 | 14 | @interface NBPhoneNumberUtil : NSObject |
15 | 15 |
|
16 | | -+ (NBPhoneNumberUtil *)sharedInstance; |
17 | | -- (instancetype)initWithMetadataHelper:(NBMetadataHelper *)helper; |
| 16 | ++ (NBPhoneNumberUtil * _Nonnull)sharedInstance; |
| 17 | +- (instancetype _Nonnull)initWithMetadataHelper:(NBMetadataHelper * _Nonnull)helper; |
18 | 18 |
|
19 | | -- (instancetype)init NS_UNAVAILABLE; |
| 19 | +- (instancetype _Nonnull)init NS_UNAVAILABLE; |
20 | 20 |
|
21 | | -@property(nonatomic, strong, readonly) NSDictionary *DIGIT_MAPPINGS; |
| 21 | +@property(nonatomic, strong, readonly, nonnull) NSDictionary * DIGIT_MAPPINGS; |
22 | 22 |
|
23 | 23 | // regular expressions |
24 | | -- (NSArray *)matchesByRegex:(NSString *)sourceString regex:(NSString *)pattern; |
25 | | -- (NSArray *)matchedStringByRegex:(NSString *)sourceString regex:(NSString *)pattern; |
26 | | -- (NSString *)replaceStringByRegex:(NSString *)sourceString |
27 | | - regex:(NSString *)pattern |
28 | | - withTemplate:(NSString *)templateString; |
29 | | -- (int)stringPositionByRegex:(NSString *)sourceString regex:(NSString *)pattern; |
| 24 | +- (NSArray * _Nullable)matchesByRegex:(NSString * _Nonnull)sourceString regex:(NSString * _Nonnull)pattern; |
| 25 | +- (NSArray * _Nullable)matchedStringByRegex:(NSString * _Nonnull)sourceString regex:(NSString * _Nonnull)pattern; |
| 26 | +- (NSString * _Nonnull)replaceStringByRegex:(NSString * _Nonnull)sourceString |
| 27 | + regex:(NSString * _Nonnull)pattern |
| 28 | + withTemplate:(NSString * _Nonnull)templateString; |
| 29 | +- (int)stringPositionByRegex:(NSString * _Nullable)sourceString regex:(NSString * _Nullable)pattern; |
30 | 30 |
|
31 | 31 | // libPhoneNumber Util functions |
32 | | -- (NSString *)convertAlphaCharactersInNumber:(NSString *)number; |
33 | | - |
34 | | -- (NSString *)normalize:(NSString *)phoneNumber; |
35 | | -- (NSString *)normalizeDigitsOnly:(NSString *)number; |
36 | | -- (NSString *)normalizeDiallableCharsOnly:(NSString *)number; |
37 | | - |
38 | | -- (BOOL)isNumberGeographical:(NBPhoneNumber *)phoneNumber; |
39 | | - |
40 | | -- (NSString *)extractPossibleNumber:(NSString *)phoneNumber; |
41 | | -- (NSNumber *)extractCountryCode:(NSString *)fullNumber nationalNumber:(NSString **)nationalNumber; |
42 | | -- (NSString *)countryCodeByCarrier; |
43 | | - |
44 | | -- (NSString *)getNddPrefixForRegion:(NSString *)regionCode stripNonDigits:(BOOL)stripNonDigits; |
45 | | -- (NSString *)getNationalSignificantNumber:(NBPhoneNumber *)phoneNumber; |
46 | | - |
47 | | -- (NSArray *)getSupportedRegions; |
48 | | - |
49 | | -- (NBEPhoneNumberType)getNumberType:(NBPhoneNumber *)phoneNumber; |
50 | | - |
51 | | -- (NSNumber *)getCountryCodeForRegion:(NSString *)regionCode; |
52 | | - |
53 | | -- (NSString *)getRegionCodeForCountryCode:(NSNumber *)countryCallingCode; |
54 | | -- (NSArray *)getRegionCodesForCountryCode:(NSNumber *)countryCallingCode; |
55 | | -- (NSString *)getRegionCodeForNumber:(NBPhoneNumber *)phoneNumber; |
56 | | - |
57 | | -- (NBPhoneNumber *)getExampleNumber:(NSString *)regionCode error:(NSError **)error; |
58 | | -- (NBPhoneNumber *)getExampleNumberForType:(NSString *)regionCode |
59 | | - type:(NBEPhoneNumberType)type |
60 | | - error:(NSError **)error; |
61 | | -- (NBPhoneNumber *)getExampleNumberForNonGeoEntity:(NSNumber *)countryCallingCode |
62 | | - error:(NSError **)error; |
63 | | - |
64 | | -- (BOOL)canBeInternationallyDialled:(NBPhoneNumber *)number error:(NSError **)error; |
65 | | - |
66 | | -- (BOOL)truncateTooLongNumber:(NBPhoneNumber *)number; |
67 | | - |
68 | | -- (BOOL)isValidNumber:(NBPhoneNumber *)number; |
69 | | -- (BOOL)isViablePhoneNumber:(NSString *)phoneNumber; |
70 | | -- (BOOL)isAlphaNumber:(NSString *)number; |
71 | | -- (BOOL)isValidNumberForRegion:(NBPhoneNumber *)number regionCode:(NSString *)regionCode; |
72 | | -- (BOOL)isNANPACountry:(NSString *)regionCode; |
73 | | -- (BOOL)isLeadingZeroPossible:(NSNumber *)countryCallingCode; |
74 | | - |
75 | | -- (NBEValidationResult)isPossibleNumberWithReason:(NBPhoneNumber *)number error:(NSError **)error; |
76 | | - |
77 | | -- (BOOL)isPossibleNumber:(NBPhoneNumber *)number; |
78 | | -- (BOOL)isPossibleNumber:(NBPhoneNumber *)number error:(NSError **)error; |
79 | | -- (BOOL)isPossibleNumberString:(NSString *)number |
80 | | - regionDialingFrom:(NSString *)regionDialingFrom |
81 | | - error:(NSError **)error; |
82 | | - |
83 | | -- (NBEMatchType)isNumberMatch:(id)firstNumberIn second:(id)secondNumberIn error:(NSError **)error; |
84 | | - |
85 | | -- (int)getLengthOfGeographicalAreaCode:(NBPhoneNumber *)phoneNumber error:(NSError **)error; |
86 | | -- (int)getLengthOfNationalDestinationCode:(NBPhoneNumber *)phoneNumber error:(NSError **)error; |
87 | | - |
88 | | -- (BOOL)maybeStripNationalPrefixAndCarrierCode:(NSString **)numberStr |
89 | | - metadata:(NBPhoneMetaData *)metadata |
90 | | - carrierCode:(NSString **)carrierCode; |
91 | | -- (NBECountryCodeSource)maybeStripInternationalPrefixAndNormalize:(NSString **)numberStr |
92 | | - possibleIddPrefix:(NSString *)possibleIddPrefix; |
93 | | - |
94 | | -- (NSNumber *)maybeExtractCountryCode:(NSString *)number |
95 | | - metadata:(NBPhoneMetaData *)defaultRegionMetadata |
96 | | - nationalNumber:(NSString **)nationalNumber |
97 | | - keepRawInput:(BOOL)keepRawInput |
98 | | - phoneNumber:(NBPhoneNumber **)phoneNumber |
99 | | - error:(NSError **)error; |
100 | | - |
101 | | -- (NBPhoneNumber *)parse:(NSString *)numberToParse |
102 | | - defaultRegion:(NSString *)defaultRegion |
103 | | - error:(NSError **)error; |
104 | | -- (NBPhoneNumber *)parseAndKeepRawInput:(NSString *)numberToParse |
105 | | - defaultRegion:(NSString *)defaultRegion |
106 | | - error:(NSError **)error; |
107 | | -- (NBPhoneNumber *)parseWithPhoneCarrierRegion:(NSString *)numberToParse error:(NSError **)error; |
108 | | - |
109 | | -- (NSString *)format:(NBPhoneNumber *)phoneNumber |
110 | | - numberFormat:(NBEPhoneNumberFormat)numberFormat |
111 | | - error:(NSError **)error; |
112 | | -- (NSString *)formatByPattern:(NBPhoneNumber *)number |
113 | | - numberFormat:(NBEPhoneNumberFormat)numberFormat |
114 | | - userDefinedFormats:(NSArray *)userDefinedFormats |
115 | | - error:(NSError **)error; |
116 | | -- (NSString *)formatNumberForMobileDialing:(NBPhoneNumber *)number |
117 | | - regionCallingFrom:(NSString *)regionCallingFrom |
118 | | - withFormatting:(BOOL)withFormatting |
119 | | - error:(NSError **)error; |
120 | | -- (NSString *)formatOutOfCountryCallingNumber:(NBPhoneNumber *)number |
121 | | - regionCallingFrom:(NSString *)regionCallingFrom |
122 | | - error:(NSError **)error; |
123 | | -- (NSString *)formatOutOfCountryKeepingAlphaChars:(NBPhoneNumber *)number |
124 | | - regionCallingFrom:(NSString *)regionCallingFrom |
125 | | - error:(NSError **)error; |
126 | | -- (NSString *)formatNationalNumberWithCarrierCode:(NBPhoneNumber *)number |
127 | | - carrierCode:(NSString *)carrierCode |
128 | | - error:(NSError **)error; |
129 | | -- (NSString *)formatInOriginalFormat:(NBPhoneNumber *)number |
130 | | - regionCallingFrom:(NSString *)regionCallingFrom |
131 | | - error:(NSError **)error; |
132 | | -- (NSString *)formatNationalNumberWithPreferredCarrierCode:(NBPhoneNumber *)number |
133 | | - fallbackCarrierCode:(NSString *)fallbackCarrierCode |
134 | | - error:(NSError **)error; |
135 | | -- (BOOL)formattingRuleHasFirstGroupOnly:(NSString *)nationalPrefixFormattingRule; |
| 32 | +- (NSString * _Nonnull)convertAlphaCharactersInNumber:(NSString * _Nonnull)number; |
| 33 | + |
| 34 | +- (NSString * _Nonnull)normalize:(NSString * _Nonnull)number; |
| 35 | +- (NSString * _Nonnull)normalizeDigitsOnly:(NSString * _Nonnull)number; |
| 36 | +- (NSString * _Nonnull)normalizeDiallableCharsOnly:(NSString * _Nonnull)number; |
| 37 | + |
| 38 | +- (BOOL)isNumberGeographical:(NBPhoneNumber * _Nonnull)phoneNumber; |
| 39 | + |
| 40 | +- (NSString * _Nonnull)extractPossibleNumber:(NSString * _Nonnull)number; |
| 41 | +- (NSNumber * _Nonnull)extractCountryCode:(NSString * _Nonnull)fullNumber nationalNumber:(NSString * _Nullable * _Nullable)nationalNumber; |
| 42 | +- (NSString * _Nonnull)countryCodeByCarrier; |
| 43 | + |
| 44 | +- (NSString * _Nullable)getNddPrefixForRegion:(NSString * _Nullable)regionCode stripNonDigits:(BOOL)stripNonDigits; |
| 45 | +- (NSString * _Nonnull)getNationalSignificantNumber:(NBPhoneNumber * _Nonnull)phoneNumber; |
| 46 | + |
| 47 | +- (NSArray * _Nullable)getSupportedRegions; |
| 48 | + |
| 49 | +- (NBEPhoneNumberType)getNumberType:(NBPhoneNumber * _Nonnull)phoneNumber; |
| 50 | + |
| 51 | +- (NSNumber * _Nonnull)getCountryCodeForRegion:(NSString * _Nullable)regionCode; |
| 52 | + |
| 53 | +- (NSString * _Nonnull)getRegionCodeForCountryCode:(NSNumber * _Nonnull)countryCallingCode; |
| 54 | +- (NSArray * _Nullable)getRegionCodesForCountryCode:(NSNumber * _Nonnull)countryCallingCode; |
| 55 | +- (NSString * _Nullable)getRegionCodeForNumber:(NBPhoneNumber * _Nullable)phoneNumber; |
| 56 | + |
| 57 | +- (NBPhoneNumber * _Nullable)getExampleNumber:(NSString * _Nonnull)regionCode error:(NSError * _Nullable __autoreleasing * _Nullable)error; |
| 58 | +- (NBPhoneNumber * _Nullable)getExampleNumberForType:(NSString * _Nonnull)regionCode |
| 59 | + type:(NBEPhoneNumberType)type |
| 60 | + error:(NSError * _Nullable __autoreleasing * _Nullable)error; |
| 61 | +- (NBPhoneNumber * _Nullable)getExampleNumberForNonGeoEntity:(NSNumber * _Nonnull)countryCallingCode |
| 62 | + error:(NSError * _Nullable * _Nullable)error; |
| 63 | + |
| 64 | +- (BOOL)canBeInternationallyDialled:(NBPhoneNumber * _Nonnull)number error:(NSError * _Nullable * _Nullable)error; |
| 65 | + |
| 66 | +- (BOOL)truncateTooLongNumber:(NBPhoneNumber * _Nonnull)number; |
| 67 | + |
| 68 | +- (BOOL)isValidNumber:(NBPhoneNumber * _Nonnull)number; |
| 69 | +- (BOOL)isViablePhoneNumber:(NSString * _Nonnull)phoneNumber; |
| 70 | +- (BOOL)isAlphaNumber:(NSString * _Nonnull)number; |
| 71 | +- (BOOL)isValidNumberForRegion:(NBPhoneNumber * _Nonnull)number regionCode:(NSString * _Nonnull)regionCode; |
| 72 | +- (BOOL)isNANPACountry:(NSString * _Nullable)regionCode; |
| 73 | +- (BOOL)isLeadingZeroPossible:(NSNumber * _Nonnull)countryCallingCode; |
| 74 | + |
| 75 | +- (NBEValidationResult)isPossibleNumberWithReason:(NBPhoneNumber * _Nonnull)number |
| 76 | + error:(NSError * _Nullable * _Nullable)error; |
| 77 | + |
| 78 | +- (BOOL)isPossibleNumber:(NBPhoneNumber * _Nonnull)number; |
| 79 | +- (BOOL)isPossibleNumber:(NBPhoneNumber * _Nonnull)number error:(NSError * _Nullable * _Nullable)error; |
| 80 | +- (BOOL)isPossibleNumberString:(NSString * _Nonnull)number |
| 81 | + regionDialingFrom:(NSString * _Nullable)regionDialingFrom |
| 82 | + error:(NSError * _Nullable * _Nullable)error; |
| 83 | + |
| 84 | +- (NBEMatchType)isNumberMatch:(id _Nonnull)firstNumberIn second:(id _Nonnull)secondNumberIn error:(NSError * _Nullable * _Nullable)error; |
| 85 | + |
| 86 | +- (int)getLengthOfGeographicalAreaCode:(NBPhoneNumber * _Nonnull)phoneNumber error:(NSError * _Nullable * _Nullable)error; |
| 87 | +- (int)getLengthOfNationalDestinationCode:(NBPhoneNumber * _Nonnull)phoneNumber error:(NSError * _Nullable * _Nullable)error; |
| 88 | + |
| 89 | +- (BOOL)maybeStripNationalPrefixAndCarrierCode:(NSString * _Nullable * _Nullable)number |
| 90 | + metadata:(NBPhoneMetaData * _Nonnull)metadata |
| 91 | + carrierCode:(NSString * _Nullable * _Nullable)carrierCode; |
| 92 | +- (NBECountryCodeSource)maybeStripInternationalPrefixAndNormalize:(NSString * _Nullable * _Nullable)numberStr |
| 93 | + possibleIddPrefix:(NSString * _Nonnull)possibleIddPrefix; |
| 94 | + |
| 95 | +- (NSNumber * _Nonnull)maybeExtractCountryCode:(NSString * _Nonnull)number |
| 96 | + metadata:(NBPhoneMetaData * _Nullable)defaultRegionMetadata |
| 97 | + nationalNumber:(NSString * _Nullable * _Nullable)nationalNumber |
| 98 | + keepRawInput:(BOOL)keepRawInput |
| 99 | + phoneNumber:(NBPhoneNumber * _Nullable * _Nullable)phoneNumber |
| 100 | + error:(NSError * _Nullable * _Nullable)error; |
| 101 | + |
| 102 | +- (NBPhoneNumber * _Nullable)parse:(NSString * _Nullable)numberToParse |
| 103 | + defaultRegion:(NSString * _Nullable)defaultRegion |
| 104 | + error:(NSError * _Nullable * _Nullable)error; |
| 105 | +- (NBPhoneNumber * _Nullable)parseAndKeepRawInput:(NSString * _Nonnull)numberToParse |
| 106 | + defaultRegion:(NSString * _Nullable)defaultRegion |
| 107 | + error:(NSError * _Nullable * _Nullable)error; |
| 108 | +- (NBPhoneNumber * _Nullable)parseWithPhoneCarrierRegion:(NSString * _Nullable)numberToParse |
| 109 | + error:(NSError * _Nullable * _Nullable)error; |
| 110 | + |
| 111 | +- (NSString * _Nullable)format:(NBPhoneNumber * _Nonnull)phoneNumber |
| 112 | + numberFormat:(NBEPhoneNumberFormat)numberFormat |
| 113 | + error:(NSError * _Nullable * _Nullable)error; |
| 114 | +- (NSString * _Nullable)formatByPattern:(NBPhoneNumber * _Nonnull)number |
| 115 | + numberFormat:(NBEPhoneNumberFormat)numberFormat |
| 116 | + userDefinedFormats:(NSArray * _Nullable)userDefinedFormats |
| 117 | + error:(NSError * _Nullable * _Nullable)error; |
| 118 | +- (NSString * _Nullable)formatNumberForMobileDialing:(NBPhoneNumber * _Nonnull)number |
| 119 | + regionCallingFrom:(NSString * _Nonnull)regionCallingFrom |
| 120 | + withFormatting:(BOOL)withFormatting |
| 121 | + error:(NSError * _Nullable * _Nullable)error; |
| 122 | +- (NSString * _Nullable)formatOutOfCountryCallingNumber:(NBPhoneNumber * _Nonnull)number |
| 123 | + regionCallingFrom:(NSString * _Nonnull)regionCallingFrom |
| 124 | + error:(NSError * _Nullable * _Nullable)error; |
| 125 | +- (NSString * _Nullable)formatOutOfCountryKeepingAlphaChars:(NBPhoneNumber * _Nonnull)number |
| 126 | + regionCallingFrom:(NSString * _Nonnull)regionCallingFrom |
| 127 | + error:(NSError * _Nullable * _Nullable)error; |
| 128 | +- (NSString * _Nullable)formatNationalNumberWithCarrierCode:(NBPhoneNumber * _Nonnull)number |
| 129 | + carrierCode:(NSString * _Nullable)carrierCode |
| 130 | + error:(NSError * _Nullable * _Nullable)error; |
| 131 | +- (NSString * _Nullable)formatInOriginalFormat:(NBPhoneNumber * _Nonnull)number |
| 132 | + regionCallingFrom:(NSString * _Nonnull)regionCallingFrom |
| 133 | + error:(NSError * _Nullable * _Nullable)error; |
| 134 | +- (NSString * _Nullable)formatNationalNumberWithPreferredCarrierCode:(NBPhoneNumber * _Nonnull)number |
| 135 | + fallbackCarrierCode:(NSString * _Nonnull)fallbackCarrierCode |
| 136 | + error:(NSError * _Nullable * _Nullable)error; |
| 137 | +- (BOOL)formattingRuleHasFirstGroupOnly:(NSString * _Nullable)nationalPrefixFormattingRule; |
136 | 138 |
|
137 | 139 | /** |
138 | 140 | * Returns the mobile token for the provided country calling code if it has one, otherwise |
|
142 | 144 | * @param countryCallingCode the country calling code for which we want the mobile token. |
143 | 145 | * @return the mobile token, as a string, for the given country calling code. |
144 | 146 | */ |
145 | | -- (NSString *)getCountryMobileTokenFromCountryCode:(NSInteger)countryCallingCode; |
| 147 | +- (NSString * _Nonnull)getCountryMobileTokenFromCountryCode:(NSInteger)countryCallingCode; |
146 | 148 |
|
147 | 149 | @end |
| 150 | + |
0 commit comments