FirebasePhoneNumberVerification

public interface FirebasePhoneNumberVerification


Entry point for Firebase Phone Number Verification.

Summary

Public methods

abstract void

Enables test session with single-SIM support for Firebase Phone Number Verification.

abstract @NonNull Task<@NonNull VerifiedPhoneNumberTokenResult>

Completes the phone number verification process by exchanging a response from Credential Manager for a verified phone number token.

abstract @NonNull Task<@NonNull String>

Prepares for a phone number verification flow by performing preflight checks and returning a digital credential payload for use with Android's Credential Manager.

default static final @NonNull FirebasePhoneNumberVerification

Returns a singleton instance of FirebasePhoneNumberVerification for the default FirebaseApp.

default static final @NonNull FirebasePhoneNumberVerification

Returns a singleton instance of FirebasePhoneNumberVerification for the given FirebaseApp.

abstract @NonNull Task<@NonNull List<@NonNull VerificationSupportResult>>

Checks if phone number verification is supported for all SIMs.

abstract @NonNull Task<@NonNull List<@NonNull VerificationSupportResult>>

Checks if phone number verification is supported for a specific simSlot.

abstract @NonNull Task<@NonNull VerifiedPhoneNumberTokenResult>

Initiates the end-to-end phone number verification process.

Public methods

enableTestSession

abstract void enableTestSession(@NonNull String testNumberId)

Enables test session with single-SIM support for Firebase Phone Number Verification.

When test session is enabled, the verification flow will use test number(s), simulate an end to end flow, but will not perform actual SIM checks. This is intended for development and testing purposes only.

The testNumberId is a string representing a test number identifier (ID) that was acquired from the Firebase Console. This ID is used to simulate a single SIM environment in test session. The string must not be empty.

A com.google.firebase.pnv.FirebasePhoneNumberVerificationException is thrown if this method or its overloads are called more than once, or if testNumberId is empty.

exchangeCredentialResponseForPhoneNumber

abstract @NonNull Task<@NonNull VerifiedPhoneNumberTokenResult> exchangeCredentialResponseForPhoneNumber(@NonNull String dcApiResponse)

Completes the phone number verification process by exchanging a response from Credential Manager for a verified phone number token.

getDigitalCredentialPayload

abstract @NonNull Task<@NonNull String> getDigitalCredentialPayload(@NonNull String nonce)

Prepares for a phone number verification flow by performing preflight checks and returning a digital credential payload for use with Android's Credential Manager.

Parameters
@NonNull String nonce

A unique string used to prevent replay attacks. screen.

getInstance

default static final @NonNull FirebasePhoneNumberVerification getInstance()

Returns a singleton instance of FirebasePhoneNumberVerification for the default FirebaseApp.

Methods that require an Activity context, such as getVerifiedPhoneNumber, take the Context as a parameter.

getInstance

default static final @NonNull FirebasePhoneNumberVerification getInstance(@NonNull FirebaseApp firebaseApp)

Returns a singleton instance of FirebasePhoneNumberVerification for the given FirebaseApp.

Methods that require an Activity context, such as getVerifiedPhoneNumber, take the Context as a parameter.

getVerificationSupportInfo

abstract @NonNull Task<@NonNull List<@NonNull VerificationSupportResult>> getVerificationSupportInfo()

Checks if phone number verification is supported for all SIMs.

This is a pre-check to determine if the verification flow is likely to succeed and does not require user consent.

The returned Task completes with a list of VerificationSupportResult objects containing information about verification support for all SIM slots.

getVerificationSupportInfo

abstract @NonNull Task<@NonNull List<@NonNull VerificationSupportResult>> getVerificationSupportInfo(int simSlot)

Checks if phone number verification is supported for a specific simSlot.

This is a pre-check to determine if the verification flow is likely to succeed and does not require user consent.

The returned Task completes with a VerificationSupportResult object containing information about verification support for the specified simSlot.

Throws IllegalArgumentException if the provided simSlot is not 0 or 1.

getVerifiedPhoneNumber

abstract @NonNull Task<@NonNull VerifiedPhoneNumberTokenResult> getVerifiedPhoneNumber(@NonNull Context context)

Initiates the end-to-end phone number verification process.

This function handles the entire end-to-end flow, which includes getting a signed request, interacting with Credential Manager, and exchanging the response for a verified phone number token.

The Context to use for the verification flow must be an Activity context, as the underlying Credential Manager API launches a system UI.

A com.google.firebase.pnv.FirebasePhoneNumberVerificationException is thrown if the provided Context is not an Activity context.