Download the PHP package kz370/laravel-firebase-notifications without Composer
On this page you can find all versions of the php package kz370/laravel-firebase-notifications. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kz370/laravel-firebase-notifications
More information about kz370/laravel-firebase-notifications
Files in kz370/laravel-firebase-notifications
Package laravel-firebase-notifications
Short Description A Laravel package for sending Firebase Cloud Messaging (FCM) notifications using service accounts.
License MIT
Informations about the package laravel-firebase-notifications
🚀 kz370/laravel-firebase-notifications
A simple and flexible Laravel package for sending Firebase Cloud Messaging (FCM) notifications using a Firebase Service Account. Supports both direct (instant) and queued (asynchronous) notifications — including topic-based broadcasts.
🧩 Features
- ✅ Send notifications to individual devices or specific topics
- ✅ Supports queued notifications for scalable delivery
- ✅ Uses Firebase Admin REST API v1 (no legacy FCM keys)
- ✅ Fully configurable via
.env - ✅ Compatible with Laravel 9, 10, and 11
📦 Installation
Install via Composer:
⚙️ Configuration
Publish the configuration file:
This creates config/firebase-notifications.php.
.env Setup
Add your Firebase credentials and project ID:
💡 Tip: Download your Firebase service account key from Project Settings → Service Accounts → Generate New Private Key
🚀 Usage Examples
Send Notification to a Specific Device
Method: sendNotification()
This method sends a push notification directly to a specific device using its FCM device token.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
$deviceToken |
string |
✅ | The Firebase device token that identifies a specific user's device. You typically get this from your mobile app's Firebase SDK. |
$title |
string |
✅ | The title text of the notification, usually displayed in bold (e.g., "New Message"). |
$body |
string |
✅ | The main message content or body text of the notification. |
$imageUrl |
string\|null |
❌ | (Optional) URL of an image to display in the notification if supported by the client app. |
$data |
array |
❌ | (Optional) A custom key-value data payload sent alongside the notification. Useful for deep links or background processing. |
Send Notification to a Topic
You can send notifications to any topic your users have subscribed to. By default, the topic is "all" — but you can specify your own.
This will send the notification to all users subscribed to the topic news.
Method: sendNotificationToTopic()
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
$title |
string |
✅ | The notification title shown in the header (e.g., "System Update") |
$body |
string |
✅ | The main notification body text (e.g., "We're upgrading our system tonight.") |
$imageUrl |
string\|null |
❌ | Optional image URL to display in the notification (if supported) |
$data |
array |
❌ | Custom key-value payload for background handling or deep linking |
$topic |
string |
❌ | Target topic (default: "all") |
⏳ Using Queues
You can queue notifications for background processing using Laravel's queue system.
Queue Single Device Notification
Queue Topic Notification
Delay Notification
Make sure your queue worker is running:
⚡ Configuration Overview
config/firebase-notifications.php
🧰 Troubleshooting
invalid_grant or unauthorized_client
Check that your Firebase service account JSON file is valid and the .env path is correct.
Notification not delivered
- The device token must be valid and active
- Ensure the app is subscribed to the topic you're sending to
- The Firebase Cloud Messaging API must be enabled in Google Cloud Console
Queues not processing
Run your queue worker:
🪪 License
This package is open-source software licensed under the MIT License.
✨ Author
KZ370
💻 Laravel Developer