Download the PHP package blutrixx/nativephp-fcm without Composer
On this page you can find all versions of the php package blutrixx/nativephp-fcm. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download blutrixx/nativephp-fcm
More information about blutrixx/nativephp-fcm
Files in blutrixx/nativephp-fcm
Package nativephp-fcm
Short Description Firebase Cloud Messaging (FCM) push notification plugin for NativePHP Mobile
License MIT
Informations about the package nativephp-fcm
Blutrixx FCM
A NativePHP Mobile plugin for Firebase Cloud Messaging (FCM) push notifications on Android. Handles requesting notification permission, retrieving/refreshing the FCM registration token, and receiving + displaying incoming pushes (foreground and background). Sending pushes is your app's own job — this package only handles the device side.
Composer package: blutrixx/nativephp-fcm
Repo: joelnjoshkibona/nativephp-fcm
Current release: v1.0.0 — verified end-to-end on a real Android device (device registered a
live FCM token with a real backend, a real push sent via the FCM HTTP v1 API was received and
displayed).
Requirements
- PHP ^8.1
- A Laravel app running under
nativephp/mobile^3.3 (enforced bycomposer.json; 4.x is not supported yet), Android only (no iOS support in this package) - A real Firebase project:
google-services.jsonin the app's root (client config) and, on the server side, a service-account key for actually sending pushes (this package doesn't send — see Sending pushes below). Both must belong to the same Firebase project — a token registered under one project cannot receive pushes sent via another project's service account. - Android: requests
POST_NOTIFICATIONSpermission (Android 13+ only; notifications are enabled by default on older versions)
Installation
Not on Packagist yet.
As a git submodule (how this repo itself consumes it):
Without a submodule:
Laravel auto-discovers FcmServiceProvider. There's no facade — see
How the bridge works for why.
How the bridge works
All three bridge functions are synchronous — no async download/progress lifecycle like
nativephp-mobile-updater. There's no PHP facade because nothing here has a meaningful
server-side equivalent to call; every method is invoked directly from JS via BridgeCall.
Incoming pushes are handled entirely native-side by NativePHPFirebaseMessagingService
(Android's FirebaseMessagingService) — there's no PHP involvement in receiving/displaying a
push. A new/refreshed FCM token during RequestPermission fires a TokenGenerated event the
same way nativephp-mobile-updater's download events work (matching by .endsWith() on the
event name — see that package's README for the exact JS listener pattern).
A data-only push with type=gateway_wake starts blutrixx/nativephp-telephony-gateway's
TelephonyGatewayService with its ACTION_POLL_NOW action if that plugin is registered in
the same app; otherwise it is logged at debug level and ignored. The coupling is by class-name
string only, so this package builds and runs without telephony-gateway.
API reference
| Method | Sync? | Returns | Notes |
|---|---|---|---|
GetToken() |
Sync | {token: string} |
Reads the current FCM token. Falls back to the last token cached in SharedPreferences (by onNewToken) if the live Firebase call fails. |
RequestPermission() |
Sync (blocks on token fetch) | {token: string} |
Requests POST_NOTIFICATIONS (Android 13+) if not already granted, then fetches/caches the FCM token and dispatches TokenGenerated once available. |
CheckPermission() |
Sync | {status: 'granted' \| 'denied'} |
Checks current permission state without requesting it. |
Sending pushes (not this package's job)
This package never talks to Firebase's send API — that's a server-side concern with its own
service-account credential, entirely separate from google-services.json (which only configures
the client). Your backend needs its own FCM HTTP v1 API integration (or a library like
kreait/firebase-php) to actually deliver a push to a token this package retrieved.
Quick start: full push flow
The pattern this package's own test app (MOBILE_APP) uses, end to end — request permission +
register the token after login, then re-register automatically whenever FCM rotates the token:
A device-token registration endpoint isn't part of this package (it's ordinary backend CRUD —
match a token to a user, deactivate it on a failed send) — the shape above is what this test app's
UserDeviceTokensModel/DeviceTokenController implement, one reasonable way to do it.
Android manifest impact
- Permission:
android.permission.POST_NOTIFICATIONS - Service:
com.nativephp.firebase.push.NativePHPFirebaseMessagingService, intent-filtered oncom.google.firebase.MESSAGING_EVENT - Requires
google-services.jsonat the app root and the Google Services Gradle plugin (already present in NativePHP Mobile's defaultbuild.gradle.kts—id("com.google.gms.google-services"))