-
Notifications
You must be signed in to change notification settings - Fork 483
Add default phone number to the Phone Auth number flow. #334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly good, had a few comments.
} | ||
|
||
- (void)signInWithDefaultValue:(nullable NSString *)defaultValue | ||
presentingViewController:(nullable UIViewController *)presentingViewController |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: colon alignment
FirebaseGoogleAuthUI/FUIGoogleAuth.m
Outdated
} | ||
|
||
- (void)signInWithDefaultValue:(nullable NSString *)defaultValue | ||
presentingViewController:(nullable UIViewController *)presentingViewController |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: colon alignment
a raw phone number and country code. | ||
@return object or nil if any of the required parameters is nil. | ||
*/ | ||
- (instancetype)initWithNormalizedPhoneNumber:(NSString *)normalizedPhoneNumber; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These three initializers need to return nullable instancetype
, not instancetype
.
@param countryCode (required) The country code information | ||
@return object or nil if any of the required parameters is nil. | ||
*/ | ||
- (instancetype)initWithRawPhoneNumber:(NSString *)rawPhoneNumber |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nullable instancetype
@param countryCode (required) The country code information | ||
@return object or nil if any of the required parameters is nil. | ||
*/ | ||
- (instancetype)initWithNormalizedPhoneNumber:(NSString *)normalizedPhoneNumber |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nullable instancetype
|
||
- (instancetype)init __unavailable; | ||
|
||
- (BOOL)validate:(NSError **)error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add docs comments to this method.
NSParameterAssert(rawPhoneNumber); | ||
NSParameterAssert(countryCode); | ||
if (!normalizedPhoneNumber || !rawPhoneNumber || !countryCode){ | ||
return nil; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this return statement should be unreachable given the assertions above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is the only point where we return nil and it's unreachable, maybe the method signature should be modified to return a nonnull type and this code should be removed.
if (error) { | ||
*error = [NSError errorWithDomain:FUIPhoneNumberValidationErrorDomain | ||
code:FUIPhoneNumberValidationErrorMissingPlus | ||
userInfo:nil]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be adding userInfo dictionaries with description keys, so meaningful error messages appear when the errors are logged.
if (error) { | ||
*error = [NSError errorWithDomain:FUIPhoneNumberValidationErrorDomain | ||
code:FUIPhoneNumberValidationErrorMissingDialCode | ||
userInfo:nil]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above
- (instancetype)initWithNibName:(nullable NSString *)nibNameOrNil | ||
bundle:(nullable NSBundle *)nibBundleOrNil | ||
authUI:(FUIAuth *)authUI { | ||
return [self initWithNibName:NSStringFromClass([self class]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this initializer ignore the nib and bundle parameters?
Morgan, thanks for all your comments! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, pending a few comments about assertions/nullability in the initializers.
|
||
@implementation FUIPhoneNumber | ||
|
||
- (nullable instancetype)initWithNormalizedPhoneNumber:(NSString *)normalizedPhoneNumber { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function takes a nonnull normalizedPhoneNumber
, so maybe instead of returning nil
we can assert and return a nonnull type as well.
- (nullable instancetype)initWithNormalizedPhoneNumber:(NSString *)normalizedPhoneNumber | ||
rawPhoneNumber:(NSString *)rawPhoneNumber | ||
countryCode:(FUICountryCodeInfo *)countryCode { | ||
if (!normalizedPhoneNumber || !rawPhoneNumber || !countryCode){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the other initializer, all of these parameters are expected to be nonnull.
return self; | ||
} | ||
|
||
- (nullable instancetype)initWithRawPhoneNumber:(NSString *)rawPhoneNumber |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the other two initializers are no longer failable, this one can be marked nonnull as well.
@morganchen12 Done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, merge whenever
Related issue: #306