File tree Expand file tree Collapse file tree 5 files changed +18
-8
lines changed
FirebasePhoneAuthUI/Sources
Public/FirebasePhoneAuthUI Expand file tree Collapse file tree 5 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -26,19 +26,19 @@ NS_ASSUME_NONNULL_BEGIN
2626@property (nonatomic , copy ) NSString *dialCode;
2727@property (nonatomic , copy ) NSNumber *level;
2828
29- /* * @property defaultCountryCodeInfo
30- @brief Get the default country code info
31- Returns the default country code. Formerly this was set via CTCarrier information, but CTCarrier is now
32- deprecated, so this value must be manually set.
33- */
34- @property (nonatomic , copy ) FUICountryCodeInfo *defaultCountryCodeInfo;
35-
3629- (NSString *)countryFlagEmoji ;
3730
3831@end
3932
4033@interface FUICountryCodes : NSObject
4134
35+ /* * @property defaultCountryCodeInfo
36+ @brief Get the default country code info
37+ The default country code. Formerly this was set via CTCarrier information, but CTCarrier is now
38+ deprecated, so this value must be manually set. Defaults to the country code for the United States.
39+ */
40+ @property (nonatomic , copy ) FUICountryCodeInfo *defaultCountryCodeInfo;
41+
4242/* * @fn count:
4343 @brief Return the number of available country codes.
4444*/
Original file line number Diff line number Diff line change @@ -117,6 +117,7 @@ - (FUICountryCodeInfo *)defaultCountryCodeInfo {
117117 if (_defaultCountryCodeInfo == nil ) {
118118 return [self countryCodeInfoForCode: kFUIDefaultCountryCode ] ?: [self countryCodeInfoAtIndex: 0 ];
119119 }
120+ return _defaultCountryCodeInfo;
120121}
121122
122123- (FUICountryCodeInfo *)countryCodeInfoForPhoneNumber : (NSString *)phoneNumber {
Original file line number Diff line number Diff line change @@ -113,6 +113,10 @@ - (instancetype)initWithNibName:(nullable NSString *)nibNameOrNil
113113 if (self) {
114114 self.title = FUIPhoneAuthLocalizedString (kPAStr_EnterPhoneTitle );
115115 _countryCodes = countryCodes ?: [[FUICountryCodes alloc ] init ];
116+ FUIPhoneAuth *provider = [authUI providerWithID: FIRPhoneAuthProviderID];
117+ NSString *defaultCountryCode = provider.defaultCountryCode ;
118+ _countryCodes.defaultCountryCodeInfo =
119+ [_countryCodes countryCodeInfoForCode: defaultCountryCode];
116120 if (phoneNumber.length ) {
117121 _phoneNumber = [[FUIPhoneNumber alloc ] initWithNormalizedPhoneNumber: phoneNumber
118122 countryCodes: _countryCodes];
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ - (instancetype)initWithNormalizedPhoneNumber:(NSString *)normalizedPhoneNumber
4040 }
4141 if (!rawPhoneNumber) {
4242 rawPhoneNumber = normalizedPhoneNumber;
43- countryCode = [ countryCodes defaultCountryCodeInfo ] ;
43+ countryCode = countryCodes. defaultCountryCodeInfo ;
4444 }
4545 return [self initWithRawPhoneNumber: rawPhoneNumber countryCode: countryCode];
4646}
Original file line number Diff line number Diff line change @@ -28,6 +28,11 @@ NS_ASSUME_NONNULL_BEGIN
2828 */
2929@property (nonatomic , readwrite ) FUIButtonAlignment buttonAlignment;
3030
31+ /* * @property defaultCountryCode
32+ Returns the default country code. If unspecified, this will default to the United States country code.
33+ */
34+ @property (nonatomic , copy , readwrite ) NSString *defaultCountryCode;
35+
3136/* * @fn bundle
3237 @brief Returns the resource bundle required by this class.
3338 */
You can’t perform that action at this time.
0 commit comments