Download the PHP package paxha/laravel-fcm without Composer
On this page you can find all versions of the php package paxha/laravel-fcm. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download paxha/laravel-fcm
More information about paxha/laravel-fcm
Files in paxha/laravel-fcm
Package laravel-fcm
Short Description This package provides (Laravel Notification) channels for sending notifications via FCM (Firebase Cloud Messaging) using HTTP v1 API.
License MIT
Informations about the package laravel-fcm
Laravel FCM (Firebase Cloud Messaging) HTTP v1 API
Introduction
This package provides (Laravel Notification) channels for sending notifications via FCM (Firebase Cloud Messaging) using HTTP v1 API. For more information about the Firebase Cloud Messaging HTTP v1 API, please refer to the official documentation: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages
Installation
To get started, you need to install the package via Composer:
Optional: Once the package is installed, you can publish the configuration file using the following command:
This will create a new fcm.php
file in your config
directory, where you can configure your FCM settings. If you
don't publish it, it will create a default channel named fcm
with the default configuration.
Configuration
You can configure your FCM settings in the fcm.php
file. Here's an example of the default configuration:
You can also set your FCM settings in your .env
file:
Please put your service account file at config
folder and set the filename with path in the .env
file.
You can create a service account file from the Google Cloud Console. For more information, please refer to the official: https://cloud.google.com/iam/docs/service-accounts-create
Usage
To send a notification, you can use the channel provided by this package. Here's an example of how to send a
notification using the fcm
channel:
Before sending the notification, you need to use our HasPushToken
trait in your notifiable model.
Create a new notification using the following command:
Post Sending Notification
After sending the notification, it will call an event, and you can listen to the event to get the response of the notification. And you can also do some other stuff after sending the notification.
In your EventServiceProvider
:
In your PostNotificationListener
:
Cleaning up unused services OPTIONAL
There are 200+ Google API services. The chances are good that you will not want them all. In order to avoid shipping
these dependencies with your code, you can run the Google\Task\Composer::cleanup
task and specify the services you want
to keep in composer.json
:
This example will remove all services other than "FirebaseCloudMessaging" when composer update or a fresh composer install is run.
IMPORTANT: If you add any services back in composer.json
, you will need to remove the vendor/google/apiclient-services
directory explicitly for the change you made to have effect: