Download the PHP package humamkerdiah/fcm-notifications without Composer
On this page you can find all versions of the php package humamkerdiah/fcm-notifications. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download humamkerdiah/fcm-notifications
More information about humamkerdiah/fcm-notifications
Files in humamkerdiah/fcm-notifications
Package fcm-notifications
Short Description A Laravel package for sending Firebase Cloud Messaging (FCM) push notifications with support for both legacy API and FCM HTTP v1 API. Features OAuth 2.0 authentication, batch processing, and comprehensive error handling.
License MIT
Informations about the package fcm-notifications
Laravel FCM Notifications
A Laravel package for sending Firebase Cloud Messaging (FCM) notifications with support for both legacy API and the new FCM HTTP v1 API.
About
Laravel FCM Notifications is a powerful package for integrating Firebase Cloud Messaging (FCM) into your Laravel application. It supports both the legacy FCM API and the new FCM HTTP v1 API (recommended). Send push notifications to individual users or groups, manage topics, and more with simple configuration and seamless integration.
Table of Contents
- Installation
- Configuration
- FCM HTTP v1 API (Recommended)
- Legacy API Support
- Usage
- Migration Guide
- License
Features
- ✅ FCM HTTP v1 API Support - OAuth 2.0 authentication with service account keys
- ✅ Legacy API Support - Backwards compatibility with server key authentication
- ✅ Easy integration with Laravel notifications
- ✅ Send notifications to single or multiple users
- ✅ Topic-based messaging for targeted notifications
- ✅ Batch processing for multiple device tokens
- ✅ Comprehensive error handling and retry mechanisms
- ✅ Support for both mobile and web push notifications
- ✅ Laravel 8, 9, 10, and 11 compatibility
Installation
You can install the package via composer:
Configuration
After installation, publish the config file:
This will create a config/fcm.php
file where you can configure your FCM settings.
FCM HTTP v1 API (Recommended)
The v1 API uses OAuth 2.0 authentication and is Google's recommended approach for FCM.
Setup for v1 API
-
Get Service Account Key:
- Go to Firebase Console
- Select your project → Project Settings → Service Accounts
- Click "Generate new private key" and download the JSON file
- Update your
.env
file:
Alternatively, you can use the GOOGLE_APPLICATION_CREDENTIALS
environment variable:
Legacy API Support
The package still supports the legacy server key authentication for backwards compatibility.
Setup for Legacy API
Update your .env
file:
Usage
Using Laravel Notifications
There are two ways to use FCM notifications in your Laravel application:
1. Using the FCM Channel Class
2. Using the Channel Name
Setting Up Your Model
Make your model use FCM notifications by implementing the routeNotificationForFcm
method:
Sending Notifications
Topic Management
Error Handling
The package provides comprehensive error handling for both API versions:
v1 API Response Format
Legacy API Response Format
Migration Guide
If you're upgrading from the legacy API to v1 API, see our Migration Guide for detailed instructions.
Testing
When testing your application, you can mock the FCM notifications:
Requirements
- PHP 7.4 or higher
- Laravel 8.0 or higher
- GuzzleHTTP 7.0 or higher
- Google Auth Library (for v1 API)
Security Considerations
- Store service account keys securely and never commit them to version control
- Use environment variables for all sensitive configuration
- Consider using Google Cloud Secret Manager in production
- Regularly rotate your service account keys
License
The MIT License (MIT). Please see License File for more information.
All versions of fcm-notifications with dependencies
guzzlehttp/guzzle Version ^7.0
firebase/php-jwt Version ^6.0
google/auth Version ^1.18
illuminate/support Version ^8.0|^9.0|^10.0|^11.0
illuminate/contracts Version ^8.0|^9.0|^10.0|^11.0
illuminate/notifications Version ^8.0|^9.0|^10.0|^11.0