[ios][auth] emit phone verify auth events
This commit is contained in:
parent
74283c5e39
commit
797780f795
|
@ -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];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue