kreait/firebase-php ^7.6 package is listed as a dependency, and the SendFcmNotification job sends notifications directly to the FCM v1 legacy HTTP API.
What Firebase is used for
FCM push notifications are dispatched for the following events:| Event | Title | Job |
|---|---|---|
| Payment received (disbursal) | Disbursals Recieved | SendDossFcmNotification |
| Payment sent | Payment Sent | SendDossFcmNotification |
| Payment received (cashier) | Payment Received | SendCashierFcmNotification |
| Insufficient funds | Insufficient funds | SendCashierFcmNotification |
| Admin broadcast | Custom title | SendFcmNotification |
url field in the data payload so the client app can deep-link to the relevant screen.
Prerequisites
- A Firebase project with Cloud Messaging enabled
- A Server Key from the Firebase project settings (Cloud Messaging → Cloud Messaging API (Legacy))
Configuration
Create or open a Firebase project
In the Firebase Console, select or create a project. Navigate to Project Settings → Cloud Messaging.
Enable the Legacy HTTP API and copy the server key
Under Cloud Messaging API (Legacy), ensure the API is enabled. Copy the Server Key.
Update the server key in the job
The server key is currently hardcoded in Replace this value with your own project’s server key. For production, move it to Then reference it in the job:
app/Jobs/SendFcmNotification.php:app/Jobs/SendFcmNotification.php
.env:.env
How push notifications are sent
SendFcmNotification sends a POST request to the FCM legacy endpoint:
registration_ids accepts an array of FCM device tokens, allowing a single job dispatch to notify multiple devices simultaneously. Errors from the FCM API are caught and written to the Laravel log via \Log::info().
The job is dispatched using dispatch(new SendFcmNotification($tokens, $title, $body, $url)).
Device token management
FCM device tokens are stored per user in theusers table:
| Column | Description |
|---|---|
fcm_last_login_device_token | Token for the user’s mobile device, updated on each login |
fcm_last_login_device_token_for_web | Token for the user’s web session |
Api/V2/NewLoginController calls:
Api/V2/RegistrationController, the fcm_last_login_device_token field is required:
Limitations
- The integration uses the FCM Legacy HTTP API, which Google deprecated. Migrate to the FCM HTTP v1 API before Google disables legacy API access.
- The server key is currently hardcoded in the job file. Move it to an environment variable before deploying to production.
- Stale tokens (devices that have been uninstalled or logged out) are not automatically removed. Implement token cleanup based on FCM
NotRegisteredorInvalidRegistrationerror responses.