From 797780f795074cc18be4370768e50c8e0e370821 Mon Sep 17 00:00:00 2001 From: Salakar Date: Tue, 3 Oct 2017 16:49:03 +0100 Subject: [PATCH 1/2] [ios][auth] emit phone verify auth events --- ios/RNFirebase/auth/RNFirebaseAuth.m | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ios/RNFirebase/auth/RNFirebaseAuth.m b/ios/RNFirebase/auth/RNFirebaseAuth.m index e38b95df..d55a50e7 100644 --- a/ios/RNFirebase/auth/RNFirebaseAuth.m +++ b/ios/RNFirebase/auth/RNFirebaseAuth.m @@ -654,7 +654,7 @@ RCT_EXPORT_METHOD(signInWithPhoneNumber:(NSString *) appName rejecter:(RCTPromiseRejectBlock) reject) { FIRApp *firApp = [FIRApp appNamed:appName]; - [[FIRPhoneAuthProvider providerWithAuth:[FIRAuth authWithApp:firApp]] verifyPhoneNumber:phoneNumber completion:^(NSString * _Nullable verificationID, NSError * _Nullable error) { + [[FIRPhoneAuthProvider providerWithAuth:[FIRAuth authWithApp:firApp]] verifyPhoneNumber:phoneNumber UIDelegate:nil completion:^(NSString * _Nullable verificationID, NSError * _Nullable error) { if (error) { [self promiseRejectAuthException:reject error:error]; } else { @@ -675,21 +675,29 @@ RCT_EXPORT_METHOD(signInWithPhoneNumber:(NSString *) appName @param RCTPromiseRejectBlock reject @return */ -// public void verifyPhoneNumber(final String appName, final String phoneNumber, final String requestKey, final int timeout) { - RCT_EXPORT_METHOD(verifyPhoneNumber:(NSString *) appName phoneNumber:(NSString *) phoneNumber requestKey:(NSString *) requestKey) { FIRApp *firApp = [FIRApp appNamed:appName]; - [[FIRPhoneAuthProvider providerWithAuth:[FIRAuth authWithApp:firApp]] verifyPhoneNumber:phoneNumber completion:^(NSString * _Nullable verificationID, NSError * _Nullable error) { + [[FIRPhoneAuthProvider providerWithAuth:[FIRAuth authWithApp:firApp]] verifyPhoneNumber:phoneNumber UIDelegate:nil completion:^(NSString * _Nullable verificationID, NSError * _Nullable error) { if (error) { NSDictionary * jsError = [self getJSError:(error)]; - // TODO emit error + NSMutableDictionary * props = [@{ + @"type": @"onVerificationFailed", + @"requestKey":requestKey, + @"state": @{@"error": jsError}, + } mutableCopy]; + [self sendJSEventWithAppName:appName title:PHONE_AUTH_STATE_CHANGED_EVENT props: props]; } else { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:verificationID forKey:@"authVerificationID"]; - // TODO emit code send + NSMutableDictionary * props = [@{ + @"type": @"onCodeSent", + @"requestKey":requestKey, + @"state": @{@"verificationId": verificationID}, + } mutableCopy]; + [self sendJSEventWithAppName:appName title:PHONE_AUTH_STATE_CHANGED_EVENT props: props]; } }]; } From 2a805439e79b9f85c43ae07f07b150a3b9c0cfc1 Mon Sep 17 00:00:00 2001 From: Salakar Date: Tue, 3 Oct 2017 16:53:15 +0100 Subject: [PATCH 2/2] [ios][auth] added missing recover email check action code --- ios/RNFirebase/auth/RNFirebaseAuth.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ios/RNFirebase/auth/RNFirebaseAuth.m b/ios/RNFirebase/auth/RNFirebaseAuth.m index d55a50e7..6b6cd208 100644 --- a/ios/RNFirebase/auth/RNFirebaseAuth.m +++ b/ios/RNFirebase/auth/RNFirebaseAuth.m @@ -558,6 +558,9 @@ RCT_EXPORT_METHOD(checkActionCode: case FIRActionCodeOperationUnknown: actionType = @"UNKNOWN"; break; + case FIRActionCodeOperationRecoverEmail: + actionType = @"RECOVER_EMAIL"; + break; } NSDictionary *result = @{@"data": @{@"email": [info dataForKey:FIRActionCodeEmailKey], @"fromEmail": [info dataForKey:FIRActionCodeFromEmailKey],}, @"actionType": actionType,};