Represents the phone number authentication mechanism. Use this class to obtain
PhoneAuthCredentials.
| class | PhoneAuthProvider.ForceResendingToken | A 'token' that can be used to force re-sending an SMS verification code. | |
| class | PhoneAuthProvider.OnVerificationStateChangedCallbacks | Registered callbacks for the different phone auth events. | |
| String | PHONE_SIGN_IN_METHOD | Unique string identifier for Phone sign-in method. |
| String | PROVIDER_ID | Unique string identifier for this provider type. |
| static PhoneAuthCredential |
getCredential(String
verificationId, String smsCode)
Returns a new instance of
AuthCredential
that is associated with a phone number.
|
| static PhoneAuthProvider |
getInstance()
This method is deprecated. Instead, use
verifyPhoneNumber(PhoneAuthOptions)
|
| static PhoneAuthProvider |
getInstance(FirebaseAuth
firebaseAuth)
This method is deprecated. Instead, use
verifyPhoneNumber(PhoneAuthOptions)
|
| void |
verifyPhoneNumber(String phoneNumber,
long timeout, TimeUnit
unit, Activity
activity,
PhoneAuthProvider.OnVerificationStateChangedCallbacks callbacks)
This method is deprecated. Instead, use
verifyPhoneNumber(PhoneAuthOptions)
|
| static void |
verifyPhoneNumber(PhoneAuthOptions
options)
Starts the phone verification process with the settings defined in
PhoneAuthOptions.
|
| void |
verifyPhoneNumber(String phoneNumber,
long timeout, TimeUnit
unit, Activity
activity,
PhoneAuthProvider.OnVerificationStateChangedCallbacks callbacks,
PhoneAuthProvider.ForceResendingToken forceResendingToken)
This method is deprecated. Instead, use
verifyPhoneNumber(PhoneAuthOptions)
|
Unique string identifier for Phone sign-in method.
Unique string identifier for this provider type.
Returns a new instance of AuthCredential
that is associated with a phone number. Used when calling
FirebaseAuth.signInWithCredential(AuthCredential) or
FirebaseUser.linkWithCredential(AuthCredential).
| verificationId | a valid verificationId retrieved by calling
verifyPhoneNumber(String, long, TimeUnit, Activity,
OnVerificationStateChangedCallbacks) |
|---|---|
| smsCode | the 6 digit SMS-code sent to the user |
This method is deprecated.
Instead, use
verifyPhoneNumber(PhoneAuthOptions)
Initializes a new PhoneAuthProvider
using the default FirebaseAuth instance.
This method is deprecated.
Instead, use
verifyPhoneNumber(PhoneAuthOptions)
Static method to initialize a new PhoneAuthProvider
for the specified Auth instance.
This method is deprecated.
Instead, use
verifyPhoneNumber(PhoneAuthOptions)
Starts the phone number verification process for the given phone number. Either
sends an SMS with a 6 digit code to the phone number specified or triggers the callback
with a complete AuthCredential
that can be used to log in the user.
The specified callback will be Activity-scoped, i.e. it will be automatically
removed during Activity.onStop().
This function is reentrant and can be called again in Activity.onStart().
No duplicated SMS will be sent out upon re-entry (before timeout).
Make sure to test all scenarios below:
AuthCredential
if Google Play services verified the phone number instantly or helped you
auto-retrieve the verification code.
PhoneAuthProvider.OnVerificationStateChangedCallbacks.onVerificationFailed(FirebaseException).| phoneNumber | the phone number for the account the user is signing up for or signing into. Make sure to pass in a phone number with country code prefixed with plus sign ('+'). |
|---|---|
| timeout | 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. Setting this to 0 will also cause
PhoneAuthProvider.OnVerificationStateChangedCallbacks.onCodeAutoRetrievalTimeOut(String)
to be called immediately. If you specified a positive value less than 30 seconds,
library will default to 30 seconds. |
| unit | the TimeUnit
for the timeout |
| activity | the Activity to which the callbacks are scoped. |
| callbacks | the callbacks to get the status of phone number verification. The callbacks
will be automatically removed when the specified activity has stopped. When a test
phone number and sms code pair is set via
FirebaseAuthSettings.setAutoRetrievedSmsCodeForPhoneNumber(String,
String) and in the Firebase console,
PhoneAuthProvider.OnVerificationStateChangedCallbacks.onCodeAutoRetrievalTimeOut(String)
will never be triggered. |
Starts the phone verification process with the settings defined in PhoneAuthOptions.
This method is deprecated.
Instead, use
verifyPhoneNumber(PhoneAuthOptions)
See
verifyPhoneNumber(String, long, TimeUnit, Activity,
OnVerificationStateChangedCallbacks) for details. This overload allows
specifying a
PhoneAuthProvider.ForceResendingToken.
| phoneNumber | the phone number for the account the user is signing up for or signing into. Make sure to pass in a phone number with country code prefixed with plus sign ('+'). |
|---|---|
| timeout | 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. Setting this to 0 will also cause
PhoneAuthProvider.OnVerificationStateChangedCallbacks.onCodeAutoRetrievalTimeOut(String)
to be called immediately. If you specified a positive value less than 30 seconds,
library will default to 30 seconds. |
| unit | the TimeUnit
for the timeout |
| activity | the Activity to which the callbacks are scoped. |
| callbacks | the callbacks to get the status of phone number verification. The callbacks
will be automatically removed when the specified activity has stopped. When a test
phone number and sms code pair is set via
FirebaseAuthSettings.setAutoRetrievedSmsCodeForPhoneNumber(String,
String) and in the Firebase console,
PhoneAuthProvider.OnVerificationStateChangedCallbacks.onCodeAutoRetrievalTimeOut(String)
will never be triggered. |
| forceResendingToken | the ForceResendingToken obtained from
PhoneAuthProvider.OnVerificationStateChangedCallbacks.onCodeSent(String,
PhoneAuthProvider.ForceResendingToken) callback to force re-sending
another verification SMS before the auto-retrieval timeout. |