FirebasePhoneNumberVerification

interface FirebasePhoneNumberVerification


Entry point for Firebase Phone Number Verification.

Summary

Public companion functions

FirebasePhoneNumberVerification

Returns a singleton instance of FirebasePhoneNumberVerification using the default FirebaseApp and its application context.

FirebasePhoneNumberVerification
getInstance(context: Context)

This function is deprecated. The Context is no longer needed during the initialization.

FirebasePhoneNumberVerification
getInstance(firebaseApp: FirebaseApp)

Returns a singleton instance of FirebasePhoneNumberVerification for the given FirebaseApp.

FirebasePhoneNumberVerification
getInstance(firebaseApp: FirebaseApp, context: Context)

This function is deprecated. The Context is no longer needed during the initialization.

Public functions

Unit
enableTestSession(testNumberId: String)

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

Task<VerifiedPhoneNumberTokenResult>

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

Task<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.

Task<List<VerificationSupportResult>>

Checks if phone number verification is supported for all SIMs.

Task<List<VerificationSupportResult>>

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

Task<VerifiedPhoneNumberTokenResult>

This function is deprecated. Use getVerifiedPhoneNumber(Context) with an Activity context instead

Task<VerifiedPhoneNumberTokenResult>

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

Public companion functions

getInstance

fun getInstance(): FirebasePhoneNumberVerification

Returns a singleton instance of FirebasePhoneNumberVerification using the default FirebaseApp and its application context.

Note that for methods that require an Activity context, using the result of this method will result in an IllegalArgumentException.

getInstance

fun getInstance(context: Context): FirebasePhoneNumberVerification

Returns an instance of FirebasePhoneNumberVerification for the given Context and the default FirebaseApp. Note that for methods that require an Activity context, providing a non-Activity context will result in an IllegalArgumentException.

The Context is no longer needed during the initialization. Use getInstance instead.

getInstance

fun getInstance(firebaseApp: FirebaseApp): FirebasePhoneNumberVerification

Returns a singleton instance of FirebasePhoneNumberVerification for the given FirebaseApp. It will be initialized with the application context.

Note that for methods that require an Activity context, using the result of this method will result in an IllegalArgumentException.

getInstance

fun getInstance(firebaseApp: FirebaseApp, context: Context): FirebasePhoneNumberVerification

Returns an instance of FirebasePhoneNumberVerification for the given FirebaseApp and a Context. The instance will be initialized with the provided Context. Note that for methods that require an Activity context, providing a non-Activity context will result in an IllegalArgumentException.

The Context is no longer needed during the initialization. Use getInstance instead.

Public functions

enableTestSession

fun enableTestSession(testNumberId: String): Unit

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

fun exchangeCredentialResponseForPhoneNumber(dcApiResponse: String): Task<VerifiedPhoneNumberTokenResult>

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

getDigitalCredentialPayload

fun getDigitalCredentialPayload(nonce: String): Task<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.

Parameters
nonce: String

A unique string used to prevent replay attacks. screen.

getVerificationSupportInfo

fun getVerificationSupportInfo(): Task<List<VerificationSupportResult>>

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

fun getVerificationSupportInfo(simSlot: Int): Task<List<VerificationSupportResult>>

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

fun getVerifiedPhoneNumber(): Task<VerifiedPhoneNumberTokenResult>

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

Use getVerifiedPhoneNumber with an Activity context instead.

getVerifiedPhoneNumber

fun getVerifiedPhoneNumber(context: Context): Task<VerifiedPhoneNumberTokenResult>

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.