# FirebasePhoneNumberVerification


```
public interface FirebasePhoneNumberVerification
```

<br />

*** ** * ** ***

Entry point for Firebase Phone Number Verification.

## Summary

| ### Public methods |
|---|---|
| `abstract void` | `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification#enableTestSession(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html testNumberId)` Enables test session with single-SIM support for Firebase Phone Number Verification. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/VerifiedPhoneNumberTokenResult>` | `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification#exchangeCredentialResponseForPhoneNumber(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html dcApiResponse)` Completes the phone number verification process by exchanging a response from Credential Manager for a verified phone number token. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html>` | `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification#getDigitalCredentialPayload(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html 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. |
| `default static final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification` | `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification#getInstance()()` Returns a singleton instance of `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification` for the default `https://firebase.google.com/docs/reference/android/com/google/firebase/FirebaseApp`. |
| `default static final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification` | `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification#getInstance(com.google.firebase.FirebaseApp)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/FirebaseApp firebaseApp)` Returns a singleton instance of `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification` for the given `https://firebase.google.com/docs/reference/android/com/google/firebase/FirebaseApp`. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/VerificationSupportResult>>` | `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification#getVerificationSupportInfo()()` Checks if phone number verification is supported for all SIMs. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/VerificationSupportResult>>` | `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification#getVerificationSupportInfo(kotlin.Int)(int simSlot)` Checks if phone number verification is supported for a specific `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification#getVerificationSupportInfo(kotlin.Int)`. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/VerifiedPhoneNumberTokenResult>` | `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification#getVerifiedPhoneNumber(android.content.Context)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/android/content/Context.html context)` 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 `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification#enableTestSession(kotlin.String)` 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 `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerificationException` is thrown if this method or its overloads are called more than once, or if `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification#enableTestSession(kotlin.String)` 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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html nonce` | A unique string used to prevent replay attacks. screen. |

### getInstance

```
default static final @NonNull FirebasePhoneNumberVerification getInstance()
```

Returns a singleton instance of `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification` for the default `https://firebase.google.com/docs/reference/android/com/google/firebase/FirebaseApp`.

Methods that require an Activity context, such as `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification#getVerifiedPhoneNumber(android.content.Context)`, take the `https://developer.android.com/reference/android/content/Context.html` as a parameter.

### getInstance

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

Returns a singleton instance of `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification` for the given `https://firebase.google.com/docs/reference/android/com/google/firebase/FirebaseApp`.

Methods that require an Activity context, such as `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification#getVerifiedPhoneNumber(android.content.Context)`, take the `https://developer.android.com/reference/android/content/Context.html` 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 `https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html` completes with a list of `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/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 `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification#getVerificationSupportInfo(kotlin.Int)`.

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

The returned `https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html` completes with a `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/VerificationSupportResult` object containing information about verification support for the specified `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification#getVerificationSupportInfo(kotlin.Int)`.

Throws `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-illegal-argument-exception/index.html` if the provided `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerification#getVerificationSupportInfo(kotlin.Int)` 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 `https://developer.android.com/reference/android/content/Context.html` to use for the verification flow must be an Activity context, as the underlying Credential Manager API launches a system UI.

A `https://firebase.google.com/docs/reference/android/com/google/firebase/pnv/FirebasePhoneNumberVerificationException` is thrown if the provided `https://developer.android.com/reference/android/content/Context.html` is not an Activity context.