-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat(android): add support for Firebase Phone Number Verification (PNV) #9045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
just1and0
wants to merge
11
commits into
main
Choose a base branch
from
feat/phone-number-verification
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
21ab6b8
feat(phone-number-verification): add support for Firebase Phone Numbe…
just1and0 17a2ff5
feat(android): add support for Firebase Phone Number Verification (PNV)
just1and0 cabc294
Merge branch 'feat/phone-number-verification' of https://github.com/i…
just1and0 5efc577
fix lint error
just1and0 6ed8e44
fix Java formatting:
just1and0 46c2008
feat(android): add support for Firebase Phone Number Verification (PNV)
just1and0 6d630cb
feat(android): add support for Firebase Phone Number Verification (PNV)
just1and0 51774b0
feat(android): add support for Firebase Phone Number Verification (PNV)
just1and0 454364c
feat(android): add support for Firebase Phone Number Verification (PNV)
just1and0 aaa302d
feat(android): add support for Firebase Phone Number Verification (PNV)
just1and0 7e9957b
feat(android): add support for Firebase Phone Number Verification (PNV)
just1and0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| --- | ||
| redirect: /phone-number-verification/usage | ||
| --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| --- | ||
| 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(); | ||
| ``` | ||
|
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(); | ||
| // ... | ||
| } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
|
just1and0 marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
|
|
||
| --- |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.