PHPackages                             tarikmanoar/firebase-pnv - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. tarikmanoar/firebase-pnv

ActiveNativephp-plugin[Authentication &amp; Authorization](/categories/authentication)

tarikmanoar/firebase-pnv
========================

Firebase Phone Number Verification (PNV) plugin for NativePHP Mobile. Verify a device's phone number with a single tap via the carrier network — no SMS codes.

v1.0.3(yesterday)02↑2900%MITPHPPHP ^8.3

Since Jun 27Pushed yesterdayCompare

[ Source](https://github.com/tarikmanoar/firebase-pnv)[ Packagist](https://packagist.org/packages/tarikmanoar/firebase-pnv)[ Docs](https://github.com/tarikmanoar/firebase-pnv)[ RSS](/packages/tarikmanoar-firebase-pnv/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (6)Versions (5)Used By (0)

Firebase Phone Number Verification (PNV) — NativePHP Mobile Plugin
==================================================================

[](#firebase-phone-number-verification-pnv--nativephp-mobile-plugin)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fbaf1f90395a87ec66660f85f68b22b90450620ac28e2628fc1117d11e56318b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746172696b6d616e6f61722f66697265626173652d706e762e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tarikmanoar/firebase-pnv)[![Total Downloads](https://camo.githubusercontent.com/5a1436cd11c85b7bd66a58e611c6c51195e3f6e2fc1f4607d703e2986f2976e6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746172696b6d616e6f61722f66697265626173652d706e762e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tarikmanoar/firebase-pnv)[![License](https://camo.githubusercontent.com/25d3ed9be37631023aa4b20006dd5ba76c6ec19d2f453f74278c10c70f84b4b0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746172696b6d616e6f61722f66697265626173652d706e762e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

A [NativePHP Mobile](https://nativephp.com/docs/mobile) plugin that wraps the official **Firebase Phone Number Verification (PNV)** Android SDK (`com.google.firebase:firebase-pnv`). It lets a Laravel/NativePHP app verify the device's phone number with a **single tap** — the number is read from the SIM via the carrier network through the Android **Credential Manager**, with **no SMS code** to receive or type.

```
use Manoar\FirebasePnv\Facades\FirebasePNV;

// Start verification — the result arrives via the Verified event.
FirebasePNV::verify();
```

> **Platform support:** Firebase PNV is an **Android-only** product. On iOS the bridge functions return an `UNSUPPORTED_PLATFORM` error so your code degrades gracefully.

---

How it works
------------

[](#how-it-works)

```
PHP                         Native (Android, Kotlin)                 Firebase / Android
──────────────────────      ───────────────────────────────────     ──────────────────────
FirebasePNV::verify()
  └─ nativephp_call(         FirebasePnvFunctions
       'FirebasePnv            .GetVerifiedPhoneNumber.execute()
        .GetVerifiedPhoneNumber') ─► FirebasePhoneNumberVerification
                                       .getInstance()
                                       .getVerifiedPhoneNumber(activity) ─► Credential Manager
                                                                            (user consent, 1 tap)
                                                                       ─► Firebase PNV backend
                                     Task.addOnSuccessListener { result }
                                       └─ NativeActionCoordinator
                                            .dispatchEvent(
                                              activity,
                                              'Manoar\FirebasePnv\Events\Verified',
                                              { phoneNumber, token, id })
   POST /_native/api/events ◄──────────  (runs JS in the WebView)
   event(new Verified(...))
   └─ your listener fires

```

The asynchronous result (objective: *handle the Credential Manager callback back to the PHP layer*) is delivered by firing a **Laravel event**. The Kotlin payload keys map 1:1 to the event class's constructor arguments (`new Verified(...$payload)`).

---

Requirements
------------

[](#requirements)

- A working **NativePHP Mobile** app (`nativephp/mobile`) targeting **Android**.
- PHP **8.3+**, Laravel 10/11/12.
- A **Firebase project** with Phone Number Verification enabled, and the standard [Firebase Android setup](https://firebase.google.com/docs/android/setup): `google-services.json` in the app module and the **google-services Gradle plugin** applied (see [Android setup](#android-setup-google-services)).

---

Installation
------------

[](#installation)

```
# 1. Require the plugin (use a path repo during local development)
composer require tarikmanoar/firebase-pnv

# 2. Register it with NativePHP (adds the provider to NativeServiceProvider)
php artisan native:plugin:register tarikmanoar/firebase-pnv

# 3. (optional) publish the config
php artisan vendor:publish --tag=firebase-pnv-config

# 4. Rebuild the native app so the Kotlin + Gradle deps are injected
php artisan native:run
```

> **Local development:** add a path repository to your app's `composer.json`before requiring it:
>
> ```
> "repositories": [
>     { "type": "path", "url": "../Packages/PNV-Plugin" }
> ]
> ```

### Android setup (google-services)

[](#android-setup-google-services)

NativePHP injects the `firebase-pnv` dependency automatically (declared in [`nativephp.json`](nativephp.json)). The one thing it **cannot** do for you is wire up Firebase config, so add Firebase to your Android project the normal way:

1. Create/register your Android app in the Firebase console and download `google-services.json`.
2. Apply the **google-services Gradle plugin** and drop `google-services.json`into the Android app module. See [`resources/android/gradle/firebase-pnv.gradle.kts`](resources/android/gradle/firebase-pnv.gradle.kts)for the exact snippet.

---

Usage
-----

[](#usage)

### Verify a phone number

[](#verify-a-phone-number)

```
use Manoar\FirebasePnv\Facades\FirebasePNV;

// Simplest form — auto-starts on the line below.
FirebasePNV::verify();

// Fluent form with a correlation id and explicit dispatch:
FirebasePNV::verify()
    ->id('checkout-42')          // correlate the result event
    ->dispatch();
```

### Check device/SIM support first

[](#check-devicesim-support-first)

```
FirebasePNV::supportInfo()->check();
// → fires Manoar\FirebasePnv\Events\SupportInfoRetrieved { supported, sims, id }
```

### Listen for the result

[](#listen-for-the-result)

The result is **always** delivered via an event — never as the return value of `verify()` (the native flow is asynchronous and shows UI).

**A. Plain Laravel listener** (works everywhere):

```
use Illuminate\Support\Facades\Event;
use Manoar\FirebasePnv\Events\Verified;
use Manoar\FirebasePnv\Events\VerificationFailed;

Event::listen(Verified::class, function (Verified $e) {
    // $e->phoneNumber, $e->token, $e->id
});

Event::listen(VerificationFailed::class, function (VerificationFailed $e) {
    // $e->code, $e->message, $e->id
});
```

See [`stubs/VerifiedListener.php`](stubs/VerifiedListener.php) for a class-based example.

**B. Livewire component** with the `#[OnNative]` attribute (live UI updates) — see [`stubs/VerifyPhoneNumber.php`](stubs/VerifyPhoneNumber.php):

```
use Native\Mobile\Attributes\OnNative;
use Manoar\FirebasePnv\Events\Verified;

#[OnNative(Verified::class)]
public function onVerified(string $phoneNumber, string $token, ?string $id = null) { /* ... */ }
```

**C. JavaScript** (optional) — see [`resources/js/firebase-pnv.js`](resources/js/firebase-pnv.js):

```
import FirebasePNV from './vendor/firebase-pnv';

FirebasePNV.onVerified(({ phoneNumber, token }) => { /* ... */ });
FirebasePNV.verify({ id: 'checkout-42' });
```

---

⚠️ Security: trust the token, not the number
--------------------------------------------

[](#️-security-trust-the-token-not-the-number)

`getVerifiedPhoneNumber()` returns both a `phoneNumber` (for display) and a **signed `token`**. Treat the raw phone number as untrusted UX data. Always send the `token` to your server and verify it (against Firebase) **before** you associate the number with a user or grant any access.

---

Test mode (no SIM, no billing)
------------------------------

[](#test-mode-no-sim-no-billing)

Firebase PNV supports a SIM-less **test session** using a token generated in the Firebase console — ideal for emulators and CI.

```
FIREBASE_PNV_TEST_TOKEN="paste-test-token-from-firebase-console"
```

When set, `verify()` and `supportInfo()` run in test mode automatically (via `enableTestSession(...)`), and `getVerifiedPhoneNumber()` returns a fixed test number. Override per call with `->test('token')`, or force production with the env left empty.

> Test mode requires the device to be enrolled in the Google system services public beta program (see the Firebase docs).

---

API reference
-------------

[](#api-reference)

### `FirebasePNV` facade

[](#firebasepnv-facade)

MethodReturnsDescription`verify()``PendingVerification`Start the full verification flow.`supportInfo()``PendingSupportInfo`Check device/SIM capability.### `PendingVerification` / `PendingSupportInfo` (fluent)

[](#pendingverification--pendingsupportinfo-fluent)

MethodDescription`->id(string)`Correlation id echoed back in the result event.`->test(?string)`Run in test-session mode (defaults to the config token).`->event(class)`Override the success event class.`->failureEvent(class)`Override the failure event class.`->remember()`Flash the id into the session (`PendingVerification::lastId()`).`->dispatch()` / `->check()`Start the flow explicitly (otherwise auto on destruct).### Events

[](#events)

EventPayload`Events\Verified``string $phoneNumber, string $token, ?string $id``Events\SupportInfoRetrieved``bool $supported, array $sims, ?string $id``Events\VerificationFailed``string $code, string $message, ?string $id`Failure `code` values: `SUPPORT_INFO_FAILED`, `NOT_SUPPORTED`, `VERIFICATION_FAILED`, `UNSUPPORTED_PLATFORM`.

### Native bridge functions

[](#native-bridge-functions)

Bridge nameAndroid classFirebase SDK call`FirebasePnv.GetVerificationSupportInfo``…FirebasePnvFunctions.GetVerificationSupportInfo``getVerificationSupportInfo()``FirebasePnv.GetVerifiedPhoneNumber``…FirebasePnvFunctions.GetVerifiedPhoneNumber``getVerifiedPhoneNumber(activity)`---

Project layout
--------------

[](#project-layout)

```
.
├── composer.json                       # type: nativephp-plugin
├── nativephp.json                      # bridge functions, events, android deps
├── config/firebase-pnv.php             # test_token
├── src/
│   ├── FirebasePnvServiceProvider.php
│   ├── PhoneNumberVerification.php     # verify() / supportInfo()
│   ├── PendingVerification.php
│   ├── PendingSupportInfo.php
│   ├── Concerns/CallsNativeBridge.php  # nativephp_call() wrapper
│   ├── Facades/FirebasePNV.php
│   └── Events/{Verified,SupportInfoRetrieved,VerificationFailed}.php
├── resources/
│   ├── android/src/com/tarikmanoar/plugins/firebasepnv/FirebasePnvFunctions.kt
│   ├── android/gradle/firebase-pnv.gradle.kts
│   ├── ios/Sources/FirebasePnv/FirebasePnvFunctions.swift   # unsupported stub
│   └── js/firebase-pnv.js
└── stubs/                              # copy-paste examples for your app

```

---

Manual integration (NativePHP Mobile v2.x)
------------------------------------------

[](#manual-integration-nativephp-mobile-v2x)

The v3 plugin loader consumes `nativephp.json` automatically. If you are on a v2.x runtime (no plugin auto-loader), wire the native side in manually:

1. Publish the native sources: `php artisan vendor:publish --tag=firebase-pnv-native`.
2. Copy [`FirebasePnvFunctions.kt`](resources/android/src/com/tarikmanoar/plugins/firebasepnv/FirebasePnvFunctions.kt)into your Android project under its package directory.
3. Register the two functions in `BridgeFunctionRegistration.kt`: ```
    registry.register("FirebasePnv.GetVerificationSupportInfo",
        FirebasePnvFunctions.GetVerificationSupportInfo(activity))
    registry.register("FirebasePnv.GetVerifiedPhoneNumber",
        FirebasePnvFunctions.GetVerifiedPhoneNumber(activity))
    ```
4. Add the Gradle dependency and google-services plugin (see the Gradle reference).

---

Support
-------

[](#support)

- 🐛 **Bugs &amp; feature requests:** [GitHub Issues](https://github.com/tarikmanoar/firebase-pnv/issues)
- 💬 **Questions:** start a [discussion](https://github.com/tarikmanoar/firebase-pnv/discussions) or email ****

---

License
-------

[](#license)

MIT © Tarik Manoar — see [LICENSE.md](LICENSE.md).

Firebase and the Firebase PNV SDK are products of Google; this plugin is an independent integration and is not affiliated with or endorsed by Google or NativePHP.

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance100

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

1d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c6f1e05b86fdecee295e9d7bdc602ee2cb54c59691f1551353853696cc70f3a6?d=identicon)[tarikmanoar](/maintainers/tarikmanoar)

---

Top Contributors

[![tarikmanoar](https://avatars.githubusercontent.com/u/17971022?v=4)](https://github.com/tarikmanoar "tarikmanoar (6 commits)")

---

Tags

androidcredential-managerfirebasekotlinlaravelnativephpnativephp-pluginphone-number-verificationphppnvlaravelfirebaseandroidnativephpphone number verificationnativephp-pluginpnvcredential-manager

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/tarikmanoar-firebase-pnv/health.svg)

```
[![Health](https://phpackages.com/badges/tarikmanoar-firebase-pnv/health.svg)](https://phpackages.com/packages/tarikmanoar-firebase-pnv)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[illuminate/database

The Illuminate Database package.

2.8k54.1M11.1k](/packages/illuminate-database)[laravel/ai

The official AI SDK for Laravel.

9782.1M162](/packages/laravel-ai)[moonshine/moonshine

Laravel administration panel

1.3k239.9k76](/packages/moonshine-moonshine)[nativephp/mobile

NativePHP for Mobile

1.0k55.0k86](/packages/nativephp-mobile)[illuminate/auth

The Illuminate Auth package.

9327.9M1.2k](/packages/illuminate-auth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
