{"id":51182778,"url":"https://github.com/tarikmanoar/firebase-pnv","last_synced_at":"2026-06-27T08:01:04.405Z","repository":{"id":367693565,"uuid":"1281934546","full_name":"tarikmanoar/firebase-pnv","owner":"tarikmanoar","description":"Firebase Phone Number Verification (PNV) plugin for NativePHP Mobile — verify a device's phone number in one tap via the carrier network (Android Credential Manager), no SMS codes.","archived":false,"fork":false,"pushed_at":"2026-06-27T06:39:15.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-27T07:14:58.165Z","etag":null,"topics":["android","credential-manager","firebase","kotlin","laravel","nativephp","nativephp-plugin","phone-number-verification","php","pnv"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tarikmanoar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-27T05:23:20.000Z","updated_at":"2026-06-27T06:39:17.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/tarikmanoar/firebase-pnv","commit_stats":null,"previous_names":["tarikmanoar/firebase-pnv"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/tarikmanoar/firebase-pnv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarikmanoar%2Ffirebase-pnv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarikmanoar%2Ffirebase-pnv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarikmanoar%2Ffirebase-pnv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarikmanoar%2Ffirebase-pnv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tarikmanoar","download_url":"https://codeload.github.com/tarikmanoar/firebase-pnv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarikmanoar%2Ffirebase-pnv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34845749,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-27T02:00:06.362Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","credential-manager","firebase","kotlin","laravel","nativephp","nativephp-plugin","phone-number-verification","php","pnv"],"created_at":"2026-06-27T08:01:03.747Z","updated_at":"2026-06-27T08:01:04.396Z","avatar_url":"https://github.com/tarikmanoar.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Firebase Phone Number Verification (PNV) — NativePHP Mobile Plugin\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/tarikmanoar/firebase-pnv.svg?style=flat-square)](https://packagist.org/packages/tarikmanoar/firebase-pnv)\n[![Total Downloads](https://img.shields.io/packagist/dt/tarikmanoar/firebase-pnv.svg?style=flat-square)](https://packagist.org/packages/tarikmanoar/firebase-pnv)\n[![License](https://img.shields.io/packagist/l/tarikmanoar/firebase-pnv.svg?style=flat-square)](LICENSE.md)\n\nA [NativePHP Mobile](https://nativephp.com/docs/mobile) plugin that wraps the\nofficial **Firebase Phone Number Verification (PNV)** Android SDK\n(`com.google.firebase:firebase-pnv`). It lets a Laravel/NativePHP app verify the\ndevice's phone number with a **single tap** — the number is read from the SIM via\nthe carrier network through the Android **Credential Manager**, with **no SMS\ncode** to receive or type.\n\n```php\nuse Manoar\\FirebasePnv\\Facades\\FirebasePNV;\n\n// Start verification — the result arrives via the Verified event.\nFirebasePNV::verify();\n```\n\n\u003e **Platform support:** Firebase PNV is an **Android-only** product. On iOS the\n\u003e bridge functions return an `UNSUPPORTED_PLATFORM` error so your code degrades\n\u003e gracefully.\n\n---\n\n## How it works\n\n```\nPHP                         Native (Android, Kotlin)                 Firebase / Android\n──────────────────────      ───────────────────────────────────     ──────────────────────\nFirebasePNV::verify()\n  └─ nativephp_call(         FirebasePnvFunctions\n       'FirebasePnv            .GetVerifiedPhoneNumber.execute()\n        .GetVerifiedPhoneNumber') ─► FirebasePhoneNumberVerification\n                                       .getInstance()\n                                       .getVerifiedPhoneNumber(activity) ─► Credential Manager\n                                                                            (user consent, 1 tap)\n                                                                       ─► Firebase PNV backend\n                                     Task.addOnSuccessListener { result }\n                                       └─ NativeActionCoordinator\n                                            .dispatchEvent(\n                                              activity,\n                                              'Manoar\\FirebasePnv\\Events\\Verified',\n                                              { phoneNumber, token, id })\n   POST /_native/api/events ◄──────────  (runs JS in the WebView)\n   event(new Verified(...)) \n   └─ your listener fires\n```\n\nThe asynchronous result (objective: *handle the Credential Manager callback back\nto the PHP layer*) is delivered by firing a **Laravel event**. The Kotlin payload\nkeys map 1:1 to the event class's constructor arguments\n(`new Verified(...$payload)`).\n\n---\n\n## Requirements\n\n- A working **NativePHP Mobile** app (`nativephp/mobile`) targeting **Android**.\n- PHP **8.3+**, Laravel 10/11/12.\n- A **Firebase project** with Phone Number Verification enabled, and the standard\n  [Firebase Android setup](https://firebase.google.com/docs/android/setup):\n  `google-services.json` in the app module and the **google-services Gradle\n  plugin** applied (see [Android setup](#android-setup-google-services)).\n\n---\n\n## Installation\n\n```bash\n# 1. Require the plugin (use a path repo during local development)\ncomposer require tarikmanoar/firebase-pnv\n\n# 2. Register it with NativePHP (adds the provider to NativeServiceProvider)\nphp artisan native:plugin:register tarikmanoar/firebase-pnv\n\n# 3. (optional) publish the config\nphp artisan vendor:publish --tag=firebase-pnv-config\n\n# 4. Rebuild the native app so the Kotlin + Gradle deps are injected\nphp artisan native:run\n```\n\n\u003e **Local development:** add a path repository to your app's `composer.json`\n\u003e before requiring it:\n\u003e ```json\n\u003e \"repositories\": [\n\u003e     { \"type\": \"path\", \"url\": \"../Packages/PNV-Plugin\" }\n\u003e ]\n\u003e ```\n\n### Android setup (google-services)\n\nNativePHP injects the `firebase-pnv` dependency automatically (declared in\n[`nativephp.json`](nativephp.json)). The one thing it **cannot** do for you is wire\nup Firebase config, so add Firebase to your Android project the normal way:\n\n1. Create/register your Android app in the Firebase console and download\n   `google-services.json`.\n2. Apply the **google-services Gradle plugin** and drop `google-services.json`\n   into the Android app module. See\n   [`resources/android/gradle/firebase-pnv.gradle.kts`](resources/android/gradle/firebase-pnv.gradle.kts)\n   for the exact snippet.\n\n---\n\n## Usage\n\n### Verify a phone number\n\n```php\nuse Manoar\\FirebasePnv\\Facades\\FirebasePNV;\n\n// Simplest form — auto-starts on the line below.\nFirebasePNV::verify();\n\n// Fluent form with a correlation id and explicit dispatch:\nFirebasePNV::verify()\n    -\u003eid('checkout-42')          // correlate the result event\n    -\u003edispatch();\n```\n\n### Check device/SIM support first\n\n```php\nFirebasePNV::supportInfo()-\u003echeck();\n// → fires Manoar\\FirebasePnv\\Events\\SupportInfoRetrieved { supported, sims, id }\n```\n\n### Listen for the result\n\nThe result is **always** delivered via an event — never as the return value of\n`verify()` (the native flow is asynchronous and shows UI).\n\n**A. Plain Laravel listener** (works everywhere):\n\n```php\nuse Illuminate\\Support\\Facades\\Event;\nuse Manoar\\FirebasePnv\\Events\\Verified;\nuse Manoar\\FirebasePnv\\Events\\VerificationFailed;\n\nEvent::listen(Verified::class, function (Verified $e) {\n    // $e-\u003ephoneNumber, $e-\u003etoken, $e-\u003eid\n});\n\nEvent::listen(VerificationFailed::class, function (VerificationFailed $e) {\n    // $e-\u003ecode, $e-\u003emessage, $e-\u003eid\n});\n```\n\nSee [`stubs/VerifiedListener.php`](stubs/VerifiedListener.php) for a class-based example.\n\n**B. Livewire component** with the `#[OnNative]` attribute (live UI updates) —\nsee [`stubs/VerifyPhoneNumber.php`](stubs/VerifyPhoneNumber.php):\n\n```php\nuse Native\\Mobile\\Attributes\\OnNative;\nuse Manoar\\FirebasePnv\\Events\\Verified;\n\n#[OnNative(Verified::class)]\npublic function onVerified(string $phoneNumber, string $token, ?string $id = null) { /* ... */ }\n```\n\n**C. JavaScript** (optional) — see [`resources/js/firebase-pnv.js`](resources/js/firebase-pnv.js):\n\n```js\nimport FirebasePNV from './vendor/firebase-pnv';\n\nFirebasePNV.onVerified(({ phoneNumber, token }) =\u003e { /* ... */ });\nFirebasePNV.verify({ id: 'checkout-42' });\n```\n\n---\n\n## ⚠️ Security: trust the token, not the number\n\n`getVerifiedPhoneNumber()` returns both a `phoneNumber` (for display) and a\n**signed `token`**. Treat the raw phone number as untrusted UX data. Always send\nthe `token` to your server and verify it (against Firebase) **before** you\nassociate the number with a user or grant any access.\n\n---\n\n## Test mode (no SIM, no billing)\n\nFirebase PNV supports a SIM-less **test session** using a token generated in the\nFirebase console — ideal for emulators and CI.\n\n```dotenv\nFIREBASE_PNV_TEST_TOKEN=\"paste-test-token-from-firebase-console\"\n```\n\nWhen set, `verify()` and `supportInfo()` run in test mode automatically (via\n`enableTestSession(...)`), and `getVerifiedPhoneNumber()` returns a fixed test\nnumber. Override per call with `-\u003etest('token')`, or force production with the\nenv left empty.\n\n\u003e Test mode requires the device to be enrolled in the Google system services\n\u003e public beta program (see the Firebase docs).\n\n---\n\n## API reference\n\n### `FirebasePNV` facade\n\n| Method | Returns | Description |\n|---|---|---|\n| `verify()` | `PendingVerification` | Start the full verification flow. |\n| `supportInfo()` | `PendingSupportInfo` | Check device/SIM capability. |\n\n### `PendingVerification` / `PendingSupportInfo` (fluent)\n\n| Method | Description |\n|---|---|\n| `-\u003eid(string)` | Correlation id echoed back in the result event. |\n| `-\u003etest(?string)` | Run in test-session mode (defaults to the config token). |\n| `-\u003eevent(class)` | Override the success event class. |\n| `-\u003efailureEvent(class)` | Override the failure event class. |\n| `-\u003eremember()` | Flash the id into the session (`PendingVerification::lastId()`). |\n| `-\u003edispatch()` / `-\u003echeck()` | Start the flow explicitly (otherwise auto on destruct). |\n\n### Events\n\n| Event | Payload |\n|---|---|\n| `Events\\Verified` | `string $phoneNumber, string $token, ?string $id` |\n| `Events\\SupportInfoRetrieved` | `bool $supported, array $sims, ?string $id` |\n| `Events\\VerificationFailed` | `string $code, string $message, ?string $id` |\n\nFailure `code` values: `SUPPORT_INFO_FAILED`, `NOT_SUPPORTED`,\n`VERIFICATION_FAILED`, `UNSUPPORTED_PLATFORM`.\n\n### Native bridge functions\n\n| Bridge name | Android class | Firebase SDK call |\n|---|---|---|\n| `FirebasePnv.GetVerificationSupportInfo` | `…FirebasePnvFunctions.GetVerificationSupportInfo` | `getVerificationSupportInfo()` |\n| `FirebasePnv.GetVerifiedPhoneNumber` | `…FirebasePnvFunctions.GetVerifiedPhoneNumber` | `getVerifiedPhoneNumber(activity)` |\n\n---\n\n## Project layout\n\n```\n.\n├── composer.json                       # type: nativephp-plugin\n├── nativephp.json                      # bridge functions, events, android deps\n├── config/firebase-pnv.php             # test_token\n├── src/\n│   ├── FirebasePnvServiceProvider.php\n│   ├── PhoneNumberVerification.php     # verify() / supportInfo()\n│   ├── PendingVerification.php\n│   ├── PendingSupportInfo.php\n│   ├── Concerns/CallsNativeBridge.php  # nativephp_call() wrapper\n│   ├── Facades/FirebasePNV.php\n│   └── Events/{Verified,SupportInfoRetrieved,VerificationFailed}.php\n├── resources/\n│   ├── android/src/com/tarikmanoar/plugins/firebasepnv/FirebasePnvFunctions.kt\n│   ├── android/gradle/firebase-pnv.gradle.kts\n│   ├── ios/Sources/FirebasePnv/FirebasePnvFunctions.swift   # unsupported stub\n│   └── js/firebase-pnv.js\n└── stubs/                              # copy-paste examples for your app\n```\n\n---\n\n## Manual integration (NativePHP Mobile v2.x)\n\nThe v3 plugin loader consumes `nativephp.json` automatically. If you are on a\nv2.x runtime (no plugin auto-loader), wire the native side in manually:\n\n1. Publish the native sources: `php artisan vendor:publish --tag=firebase-pnv-native`.\n2. Copy\n   [`FirebasePnvFunctions.kt`](resources/android/src/com/tarikmanoar/plugins/firebasepnv/FirebasePnvFunctions.kt)\n   into your Android project under its package directory.\n3. Register the two functions in `BridgeFunctionRegistration.kt`:\n   ```kotlin\n   registry.register(\"FirebasePnv.GetVerificationSupportInfo\",\n       FirebasePnvFunctions.GetVerificationSupportInfo(activity))\n   registry.register(\"FirebasePnv.GetVerifiedPhoneNumber\",\n       FirebasePnvFunctions.GetVerifiedPhoneNumber(activity))\n   ```\n4. Add the Gradle dependency and google-services plugin (see the Gradle reference).\n\n---\n\n## Support\n\n- 🐛 **Bugs \u0026 feature requests:** [GitHub Issues](https://github.com/tarikmanoar/firebase-pnv/issues)\n- 💬 **Questions:** start a [discussion](https://github.com/tarikmanoar/firebase-pnv/discussions) or email **tarikmanoar@gmail.com**\n\n---\n\n## License\n\nMIT © Tarik Manoar — see [LICENSE.md](LICENSE.md).\n\nFirebase and the Firebase PNV SDK are products of Google; this plugin is an\nindependent integration and is not affiliated with or endorsed by Google or\nNativePHP.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarikmanoar%2Ffirebase-pnv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftarikmanoar%2Ffirebase-pnv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarikmanoar%2Ffirebase-pnv/lists"}