Download the PHP package mrgarest/laravel-firebase-sender without Composer
On this page you can find all versions of the php package mrgarest/laravel-firebase-sender. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mrgarest/laravel-firebase-sender
More information about mrgarest/laravel-firebase-sender
Files in mrgarest/laravel-firebase-sender
Package laravel-firebase-sender
Short Description Laravel library for sending notifications with Firebase Cloud Messaging (FCM)
License MIT
Homepage https://github.com/mrgarest/laravel-firebase-sender
Informations about the package laravel-firebase-sender
Laravel Firebase Sender
Laravel library for sending notifications with Firebase Cloud Messaging (FCM).
❗️ This library only works with the new FCM HTTP v1 API ❗️
Installation
You can install the package via composer:
Configuration
After installing the package, you will need to publish the configuration file firebase-sender.php
After publishing the configuration file, you need to open it and add the Service account data from the Firebase console.
If you don't know how to get a Service account, here is a video from YouTube.
Usage
An example of sending a simple group notification.
To send a notification to a specific device, use setTokenDevices(string $token)
instead of setTopic(string $topic)
.
Multilingual notification
To send localized notifications, you need to use the key from your app's localization file.
An example of a localization file in an Android app:
%1$s
— will be replaced by the first argument from the array.
Notification log
If you want to use the log of sent notifications, you will also need to publish the migration file and perform the migration.
To add notification information to the log, you'll need to use an additional method before sending notifications:
This method can also take an additional value of type string, which can be used, for example, to check whether a notification was sent with a specific argument to avoid duplicate notifications.
To check if there is an additional value in the log, you can use this method:
You can also check the additional value by date range:
You can also check if notifications were sent within a specific time range: