Google is committed to advancing racial equity for Black communities. See how.

PhoneAuthOptions.Builder

public static final class PhoneAuthOptions.Builder extends Object

A Builder class for PhoneAuthOptions. Get an instance of this Builder using newBuilder() or newBuilder(FirebaseAuth).

Public Constructor Summary

Public Method Summary

PhoneAuthOptions
build()
Returns the PhoneAuthOptions that this PhoneAuthOptions.Builder has constructed.
PhoneAuthOptions.Builder
requireSmsValidation(boolean requireSmsValidation)
Specifies whether to force an SMS to be sent for second factor validation.
PhoneAuthOptions.Builder
setActivity(Activity activity)
Sets the Activity to which the callbacks are scoped.
PhoneAuthOptions.Builder
setCallbacks(PhoneAuthProvider.OnVerificationStateChangedCallbacks callbacks)
Sets the callbacks to get the status of phone number verification.
PhoneAuthOptions.Builder
setExecutor(Executor executor)
Sets the Executor on which the callbacks will be executed.
PhoneAuthOptions.Builder
setForceResendingToken(PhoneAuthProvider.ForceResendingToken forceResendingToken)
Sets the PhoneAuthProvider.ForceResendingToken to force another verification SMS to be sent before the auto-retrieval timeout.
PhoneAuthOptions.Builder
setMultiFactorHint(PhoneMultiFactorInfo phoneMultiFactorInfo)
Sets the PhoneMultiFactorInfo to use for second factor sign-in.
PhoneAuthOptions.Builder
setMultiFactorSession(MultiFactorSession multiFactorSession)
Sets the MultiFactorSession that holds the necessary data to start an SMS verification for multi-factor authentication enrollment or sign in.
PhoneAuthOptions.Builder
setPhoneNumber(String phoneNumber)
Sets the phone number for sign-in, sign-up, or second factor enrollment.
PhoneAuthOptions.Builder
setTimeout(Long timeout, TimeUnit unit)
Sets the maximum amount of time you are willing to wait for SMS auto-retrieval to be completed by the library.

Inherited Method Summary

Public Constructors

public PhoneAuthOptions.Builder (FirebaseAuth auth)

Public Methods

public PhoneAuthOptions build ()

Returns the PhoneAuthOptions that this PhoneAuthOptions.Builder has constructed.

public PhoneAuthOptions.Builder requireSmsValidation (boolean requireSmsValidation)

Specifies whether to force an SMS to be sent for second factor validation.

In some cases the phone number can be instantly verified without needing to send or enter a verification code. This feature can be disabled here, and it is enabled by default.

This is only applicable to Multi-Factor Authentication.

public PhoneAuthOptions.Builder setActivity (Activity activity)

Sets the Activity to which the callbacks are scoped.

Also sets the Executor on which to TaskExecutors.MAIN_THREAD. Cannot be called in conjunction with setExecutor(Executor).

public PhoneAuthOptions.Builder setCallbacks (PhoneAuthProvider.OnVerificationStateChangedCallbacks callbacks)

Sets 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 setAutoRetrievedSmsCodeForPhoneNumber(String, String) and in the Firebase console, onCodeAutoRetrievalTimeOut(String) will never be triggered.

public PhoneAuthOptions.Builder setExecutor (Executor executor)

Sets the Executor on which the callbacks will be executed.

Cannot be used with setActivity(Activity).

public PhoneAuthOptions.Builder setForceResendingToken (PhoneAuthProvider.ForceResendingToken forceResendingToken)

Sets the PhoneAuthProvider.ForceResendingToken to force another verification SMS to be sent before the auto-retrieval timeout.

public PhoneAuthOptions.Builder setMultiFactorHint (PhoneMultiFactorInfo phoneMultiFactorInfo)

Sets the PhoneMultiFactorInfo to use for second factor sign-in.

public PhoneAuthOptions.Builder setMultiFactorSession (MultiFactorSession multiFactorSession)

Sets the MultiFactorSession that holds the necessary data to start an SMS verification for multi-factor authentication enrollment or sign in.

When this is set, the verification will be for validating ownership of a phone SMS second factor, not for phone authentication.

public PhoneAuthOptions.Builder setPhoneNumber (String phoneNumber)

Sets the phone number for sign-in, sign-up, or second factor enrollment.

Parameters
phoneNumber a phone number that conforms to the E.164 format.

public PhoneAuthOptions.Builder setTimeout (Long timeout, TimeUnit unit)

Sets the maximum amount of time you are willing to wait for SMS auto-retrieval to be completed by the library.

The minimum timeout is 30 seconds, and the maximum timeout is 2 minutes. If you specified a positive value less than 30 seconds, library will default to 30 seconds. Specifying a negative timeout or a timeout that is greater than 120 seconds will result in an IllegalArgumentException being thrown.

Use 0 to disable SMS-auto-retrieval. This will also cause onCodeAutoRetrievalTimeOut(String) to be called immediately.

Parameters
timeout the length of the timeout in the units specified by unit.
unit the TimeUnit for the timeout.