Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit e13d7d8

Browse files
Merge pull request #1495 from kanclalg/timeout-parameter-for-phone-authentication
Feat: extend FirebasePhoneLoginOptions with android timeout parameter
2 parents ab035e4 + da9ba9b commit e13d7d8

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

docs/AUTHENTICATION.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,11 @@ Note that changing a password may fail if your login for this `email` was too lo
444444
type: firebase.LoginType.PHONE,
445445
phoneOptions: {
446446
phoneNumber: '+12345678900',
447-
verificationPrompt: "The received verification code" // default "Verification code"
447+
verificationPrompt: "The received verification code", // default "Verification code"
448+
// Optional
449+
android: {
450+
timeout: 30 // The maximum amount of time you are willing to wait for SMS auto-retrieval to be completed by the library
451+
}
448452
}
449453
}).then(
450454
function (result) {

src/firebase.android.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,9 +985,10 @@ firebase.login = arg => {
985985

986986
firebase._verifyPhoneNumberInProgress = true;
987987

988+
let timeout = arg.phoneOptions.android ? arg.phoneOptions.android.timeout : 60;
988989
com.google.firebase.auth.PhoneAuthProvider.getInstance().verifyPhoneNumber(
989990
arg.phoneOptions.phoneNumber,
990-
60, // timeout (in seconds, because of the next argument)
991+
timeout, // timeout (in seconds, because of the next argument)
991992
java.util.concurrent.TimeUnit.SECONDS,
992993
appModule.android.foregroundActivity,
993994
new OnVerificationStateChangedCallbacks());

src/firebase.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,14 @@ export interface FirebasePhoneLoginOptions {
268268
* Default: "Verification code".
269269
*/
270270
verificationPrompt?: string;
271+
android?: {
272+
/**
273+
* The maximum amount of time you are willing to wait for SMS auto-retrieval to be completed by the library. Maximum allowed value is 2 minutes. Use 0 to disable SMS-auto-retrieval. If you specified a positive value less than 30 seconds, library will default to 30 seconds.
274+
* Default: 60 (seconds)
275+
* See: https://firebase.google.com/docs/reference/android/com/google/firebase/auth/PhoneAuthProvider
276+
*/
277+
timeout: number;
278+
}
271279
}
272280

273281
export interface FirebaseGoogleLoginOptions {

0 commit comments

Comments
 (0)