Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@
{ "title": "KY Integration", "href": "/perf/ky-integration" }
]
},
{
"group": "Phone Number Verification",
"tab": "root",
"icon": "//static.invertase.io/assets/social/firebase-logo.png",
"pages": [{ "title": "Usage", "href": "/phone-number-verification/usage" }]
},
{
"group": "VertexAi",
"tab": "root",
Expand Down
2 changes: 1 addition & 1 deletion docs/perf/ky-integration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Performance Monitoring with KY
description: Monitor HTTP request performance with Firebase Performance Monitoring and KY.
previous: /perf/axios-integration
next: /vertexai/usage
next: /phone-number-verification/usage
---

# KY
Expand Down
3 changes: 3 additions & 0 deletions docs/phone-number-verification/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
redirect: /phone-number-verification/usage
---
132 changes: 132 additions & 0 deletions docs/phone-number-verification/usage/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
Comment thread
just1and0 marked this conversation as resolved.
title: Phone Number Verification
description: Installation and getting started with Phone Number Verification.
icon: //static.invertase.io/assets/social/firebase-logo.png
next: /vertexai/usage
previous: /perf/usage
---

# Installation

This module requires that the `@react-native-firebase/app` module is already setup and installed. To install the "app" module, view the
[Getting Started](/) documentation.

```bash
# Install & setup the app module
yarn add @react-native-firebase/app

# Install the phone-number-verification module
yarn add @react-native-firebase/phone-number-verification
```

> **Android only** - This module is only available on Android. The Firebase Phone Number Verification SDK does not support iOS or web platforms. Calling any method on a non-Android platform will throw an error.

# What does it do

Firebase Phone Number Verification (PNV) provides carrier-level phone number verification on Android devices without requiring SMS codes. It verifies the user's phone number directly through the device's SIM card and carrier network, providing a seamless and secure verification experience.

<YouTube id="Rua4VNxGc6o" />

Key capabilities:

- **Carrier-level verification**: Verifies phone numbers directly with the mobile carrier, without SMS.
- **No user interaction required**: The verification happens silently in the background using the device's SIM card.
- **Support detection**: Check whether the device and carrier support phone number verification before attempting it.
- **Digital Credential API**: Supports the Android Digital Credential API for custom verification flows.

# Usage

## Check verification support

Before attempting verification, check if the device's SIM card and carrier support phone number verification:

```js
import { getVerificationSupportInfo } from '@react-native-firebase/phone-number-verification';

const supportInfo = await getVerificationSupportInfo();

for (const info of supportInfo) {
console.log('SIM supported:', info.isSupported);
}
```

The method returns an array with one entry per SIM slot. Each entry indicates whether that SIM's carrier supports PNV.

## Verify a phone number

To initiate the full verification flow, which includes user consent and token generation:

```js
import { getVerifiedPhoneNumber } from '@react-native-firebase/phone-number-verification';

try {
const result = await getVerifiedPhoneNumber();
console.log('Phone number:', result.phoneNumber);
console.log('Verification token:', result.token);
} catch (error) {
console.error('Verification failed:', error);
}
```

The returned `token` can be sent to your backend server to validate the verification with Firebase.

## Custom verification with Digital Credentials

For advanced use cases, you can use the Digital Credential API flow:

```js
import {
getDigitalCredentialPayload,
exchangeCredentialResponseForPhoneNumber,
} from '@react-native-firebase/phone-number-verification';

// Step 1: Get the credential payload
const payload = await getDigitalCredentialPayload('your-unique-nonce');

// Step 2: Use the payload with Android Credential Manager
// ... (pass payload to CredentialManager API)

// Step 3: Exchange the response for a verified phone number
const result = await exchangeCredentialResponseForPhoneNumber(credentialResponse);
console.log('Phone number:', result.phoneNumber);
```

## Testing

For testing without a real SIM card, you can enable a test session using a token from the Firebase Console:

```js
import { enableTestSession } from '@react-native-firebase/phone-number-verification';

// Enable test mode - call only once
await enableTestSession('your-test-token-from-firebase-console');
```

In test mode, phone numbers follow the format: a valid country code followed by all zeros.

## Using the convenience object

You can also access all methods through a single object:

```js
import { getPhoneNumberVerification } from '@react-native-firebase/phone-number-verification';

const pnv = getPhoneNumberVerification();

const supportInfo = await pnv.getVerificationSupportInfo();
const result = await pnv.getVerifiedPhoneNumber();
```
Comment thread
just1and0 marked this conversation as resolved.
Outdated

## Platform handling

This module is Android-only. On non-Android platforms, all methods throw an error with the message "Firebase Phone Number Verification is only supported on Android." You can guard against this using `Platform.OS`:

```js
import { Platform } from 'react-native';
import { getVerificationSupportInfo } from '@react-native-firebase/phone-number-verification';

if (Platform.OS === 'android') {
const supportInfo = await getVerificationSupportInfo();
// ...
}
```
2 changes: 1 addition & 1 deletion docs/vertexai/usage/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: VertexAI
description: Installation and getting started with VertexAI.
icon: //static.invertase.io/assets/social/firebase-logo.png
next: /ai/usage
previous: /perf/ky-integration
previous: /phone-number-verification/usage
---

Vertex AI has been deprecated by Google in favor of the Firebase AI Logic SDK.
Expand Down
67 changes: 67 additions & 0 deletions packages/phone-number-verification/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Built application files
android/*/build/

# Crashlytics configuations
android/com_crashlytics_export_strings.xml

# Local configuration file (sdk path, etc)
android/local.properties

# Gradle generated files
android/.gradle/

# Signing files
android/.signing/

# User-specific configurations
android/.idea/gradle.xml
android/.idea/libraries/
android/.idea/workspace.xml
android/.idea/tasks.xml
android/.idea/.name
android/.idea/compiler.xml
android/.idea/copyright/profiles_settings.xml
android/.idea/encodings.xml
android/.idea/misc.xml
android/.idea/modules.xml
android/.idea/scopes/scope_settings.xml
android/.idea/vcs.xml
android/*.iml

# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
ios/Pods
ios/build
*project.xcworkspace*
*xcuserdata*

# OS-specific files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.dbandroid/gradle
android/gradlew
android/build
android/gradlew.bat
android/gradle/

.idea
coverage
yarn.lock
e2e/
.github
.vscode
.nyc_output
android/.settings
*.coverage.json
.circleci
.eslintignore
type-test.ts
__tests__
10 changes: 10 additions & 0 deletions packages/phone-number-verification/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 24.1.1 (2026-06-10)

### Features

- **android:** add support for Firebase Phone Number Verification (PNV)
Comment thread
just1and0 marked this conversation as resolved.
Outdated
55 changes: 55 additions & 0 deletions packages/phone-number-verification/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<p align="center">
<a href="https://rnfirebase.io">
<img width="160px" src="https://i.imgur.com/JIyBtKW.png"><br/>
</a>
<h2 align="center">React Native Firebase - Phone Number Verification</h2>
</p>

<p align="center">
<a href="https://www.npmjs.com/package/@react-native-firebase/phone-number-verification"><img src="https://img.shields.io/npm/dm/@react-native-firebase/phone-number-verification.svg?style=flat-square" alt="NPM downloads"></a>
<a href="https://www.npmjs.com/package/@react-native-firebase/phone-number-verification"><img src="https://img.shields.io/npm/v/@react-native-firebase/phone-number-verification.svg?style=flat-square" alt="NPM version"></a>
<a href="/LICENSE"><img src="https://img.shields.io/npm/l/react-native-firebase.svg?style=flat-square" alt="License"></a>
<a href="https://lerna.js.org/"><img src="https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg?style=flat-square" alt="Maintained with Lerna"></a>
</p>

<p align="center">
<a href="https://invertase.link/discord"><img src="https://img.shields.io/discord/295953187817521152.svg?style=flat-square&colorA=7289da&label=Chat%20on%20Discord" alt="Chat on Discord"></a>
<a href="https://twitter.com/rnfirebase"><img src="https://img.shields.io/twitter/follow/rnfirebase.svg?style=flat-square&colorA=1da1f2&colorB=&label=Follow%20on%20Twitter" alt="Follow on Twitter"></a>
<a href="https://www.facebook.com/groups/rnfirebase"><img src="https://img.shields.io/badge/Follow%20on%20Facebook-4172B8?logo=facebook&style=flat-square&logoColor=fff" alt="Follow on Facebook"></a>
</p>

---

Firebase Phone Number Verification (PNV) enables carrier-level phone number verification on Android devices without requiring SMS. It verifies the user's phone number directly through the device's SIM card and carrier network, providing a seamless and secure verification experience.

> **Android only** - This module is only available on Android. iOS and web platforms are not supported by the Firebase PNV SDK.

[> Learn More](https://firebase.google.com/docs/phone-number-verification)

## Installation

Requires `@react-native-firebase/app` to be installed.

```bash
yarn add @react-native-firebase/phone-number-verification
```

## Documentation

- [Quick Start](https://rnfirebase.io/phone-number-verification/usage)
- [Reference](https://rnfirebase.io/reference/phone-number-verification)

## License

- See [LICENSE](/LICENSE)

---

<p>
<img align="left" width="75px" src="https://static.invertase.io/assets/invertase/invertase-rounded.png">
<p align="left">
Built and maintained with 💛 by <a href="https://invertase.io">Invertase</a>.
</p>
</p>

---
Loading
Loading