# FirebasePhoneNumberVerification


```
interface FirebasePhoneNumberVerification
```

<br />

*** ** * ** ***

Entry point for Firebase Phone Number Verification.

## Summary

| ### Public companion functions |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/pnv/FirebasePhoneNumberVerification` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/pnv/FirebasePhoneNumberVerification#getInstance()()` Returns a singleton instance of `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/pnv/FirebasePhoneNumberVerification` for the default `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/FirebaseApp`. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/pnv/FirebasePhoneNumberVerification` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/pnv/FirebasePhoneNumberVerification#getInstance(com.google.firebase.FirebaseApp)(firebaseApp: https://firebase.google.com/docs/reference/kotlin/com/google/firebase/FirebaseApp)` Returns a singleton instance of `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/pnv/FirebasePhoneNumberVerification` for the given `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/FirebaseApp`. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/pnv/FirebasePhoneNumberVerification#enableTestSession(kotlin.String)(testNumberId: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Enables test session with single-SIM support for Firebase Phone Number Verification. |
| `https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html<https://firebase.google.com/docs/reference/kotlin/com/google/firebase/pnv/VerifiedPhoneNumberTokenResult>` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/pnv/FirebasePhoneNumberVerification#exchangeCredentialResponseForPhoneNumber(kotlin.String)(dcApiResponse: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Completes the phone number verification process by exchanging a response from Credential Manager for a verified phone number token. |
| `https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/pnv/FirebasePhoneNumberVerification#getDigitalCredentialPayload(kotlin.String)(nonce: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Prepares for a phone number verification flow by performing preflight checks and returning a digital credential payload for use with Android's Credential Manager. |
| `https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://firebase.google.com/docs/reference/kotlin/com/google/firebase/pnv/VerificationSupportResult>>` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/pnv/FirebasePhoneNumberVerification#getVerificationSupportInfo()()` Checks if phone number verification is supported for all SIMs. |
| `https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://firebase.google.com/docs/reference/kotlin/com/google/firebase/pnv/VerificationSupportResult>>` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/pnv/FirebasePhoneNumberVerification#getVerificationSupportInfo(kotlin.Int)(simSlot: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Checks if phone number verification is supported for a specific `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/pnv/FirebasePhoneNumberVerification#getVerificationSupportInfo(kotlin.Int)`. |
| `https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html<https://firebase.google.com/docs/reference/kotlin/com/google/firebase/pnv/VerifiedPhoneNumberTokenResult>` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/pnv/FirebasePhoneNumberVerification#getVerifiedPhoneNumber(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` Initiates the end-to-end phone number verification process. |

## Public companion functions

### getInstance

```
fun getInstance(): FirebasePhoneNumberVerification
```

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

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

### getInstance

```
fun getInstance(firebaseApp: FirebaseApp): FirebasePhoneNumberVerification
```

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

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

## 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 `https://firebase.google.com/docs/reference/kotlin/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/kotlin/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/kotlin/com/google/firebase/pnv/FirebasePhoneNumberVerification#enableTestSession(kotlin.String)` 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: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | 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 `https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html` completes with a list of `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/pnv/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 `https://firebase.google.com/docs/reference/kotlin/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/kotlin/com/google/firebase/pnv/VerificationSupportResult` object containing information about verification support for the specified `https://firebase.google.com/docs/reference/kotlin/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/kotlin/com/google/firebase/pnv/FirebasePhoneNumberVerification#getVerificationSupportInfo(kotlin.Int)` is not 0 or 1.

### 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 `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/kotlin/com/google/firebase/pnv/FirebasePhoneNumberVerificationException` is thrown if the provided `https://developer.android.com/reference/android/content/Context.html` is not an Activity context.