Skip to content

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

Merged
merged 4 commits into from
Sep 19, 2017

Conversation

yramanchuk
Copy link
Contributor

Related issue: #306

Copy link
Contributor

@morganchen12 morganchen12 left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: colon alignment

}

- (void)signInWithDefaultValue:(nullable NSString *)defaultValue
presentingViewController:(nullable UIViewController *)presentingViewController
Copy link
Contributor

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;
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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.

Copy link
Contributor

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];
Copy link
Contributor

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];
Copy link
Contributor

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])
Copy link
Contributor

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?

@yramanchuk
Copy link
Contributor Author

Morgan, thanks for all your comments!
PTAL.

Copy link
Contributor

@morganchen12 morganchen12 left a 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 {
Copy link
Contributor

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){
Copy link
Contributor

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
Copy link
Contributor

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.

@yramanchuk
Copy link
Contributor Author

@morganchen12 Done!

Copy link
Contributor

@morganchen12 morganchen12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, merge whenever

@yramanchuk yramanchuk merged commit 5dac6a1 into master Sep 19, 2017
@yramanchuk yramanchuk deleted the default_phone branch September 19, 2017 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants