mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-24 04:24:52 +08:00
[android][auth] add support for ForceResendingToken, closes #721
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
import User from './User';
|
||||
import ModuleBase from '../../utils/ModuleBase';
|
||||
import { getAppEventName, SharedEventEmitter } from '../../utils/events';
|
||||
import { isAndroid } from '../../utils';
|
||||
import { getLogger } from '../../utils/log';
|
||||
import { getNativeModule } from '../../utils/native';
|
||||
import INTERNALS from '../../utils/internals';
|
||||
@@ -354,7 +355,16 @@ export default class Auth extends ModuleBase {
|
||||
* Asynchronously signs in using a phone number.
|
||||
*
|
||||
*/
|
||||
signInWithPhoneNumber(phoneNumber: string): Promise<ConfirmationResult> {
|
||||
signInWithPhoneNumber(
|
||||
phoneNumber: string,
|
||||
forceResend?: boolean
|
||||
): Promise<ConfirmationResult> {
|
||||
if (isAndroid) {
|
||||
return getNativeModule(this)
|
||||
.signInWithPhoneNumber(phoneNumber, forceResend || false)
|
||||
.then(result => new ConfirmationResult(this, result.verificationId));
|
||||
}
|
||||
|
||||
return getNativeModule(this)
|
||||
.signInWithPhoneNumber(phoneNumber)
|
||||
.then(result => new ConfirmationResult(this, result.verificationId));
|
||||
@@ -367,13 +377,20 @@ export default class Auth extends ModuleBase {
|
||||
*
|
||||
* @param phoneNumber
|
||||
* @param autoVerifyTimeout Android Only
|
||||
* @param forceResend Android Only
|
||||
* @returns {PhoneAuthListener}
|
||||
*/
|
||||
verifyPhoneNumber(
|
||||
phoneNumber: string,
|
||||
autoVerifyTimeout?: number
|
||||
autoVerifyTimeout?: number,
|
||||
forceResend?: boolean
|
||||
): PhoneAuthListener {
|
||||
return new PhoneAuthListener(this, phoneNumber, autoVerifyTimeout);
|
||||
return new PhoneAuthListener(
|
||||
this,
|
||||
phoneNumber,
|
||||
autoVerifyTimeout,
|
||||
forceResend
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,8 +43,14 @@ export default class PhoneAuthListener {
|
||||
* @param auth
|
||||
* @param phoneNumber
|
||||
* @param timeout
|
||||
* @param forceResend
|
||||
*/
|
||||
constructor(auth: Auth, phoneNumber: string, timeout?: number) {
|
||||
constructor(
|
||||
auth: Auth,
|
||||
phoneNumber: string,
|
||||
timeout?: number,
|
||||
forceResend?: boolean
|
||||
) {
|
||||
this._auth = auth;
|
||||
this._reject = null;
|
||||
this._resolve = null;
|
||||
@@ -52,6 +58,7 @@ export default class PhoneAuthListener {
|
||||
this._credential = null;
|
||||
|
||||
this._timeout = timeout || 20; // 20 secs
|
||||
this._forceResending = forceResend || false;
|
||||
this._phoneAuthRequestKey = generatePushID();
|
||||
|
||||
// internal events
|
||||
@@ -86,7 +93,8 @@ export default class PhoneAuthListener {
|
||||
getNativeModule(this._auth).verifyPhoneNumber(
|
||||
phoneNumber,
|
||||
this._phoneAuthRequestKey,
|
||||
this._timeout
|
||||
this._timeout,
|
||||
this._forceResending
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user