Package Data | |
---|---|
Maintainer Username: | mbn12 |
Maintainer Contact: | bnugraha00@hotmail.com (MuhBayu) |
Package Create Date: | 2018-12-14 |
Package Last Update: | 2018-12-17 |
Language: | PHP |
License: | Unknown |
Last Refreshed: | 2024-11-23 03:10:23 |
Package Statistics | |
---|---|
Total Downloads: | 0 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
To get the latest version of FCM on your project, require it from "composer":
$ composer require muhbayu\laravel-firebase-cloud-messaging
Register the provider directly in your app configuration file config/app.php
'providers' => [
// ...
MuhBayu\Fcm\FcmServiceProvider::class,
]
Publish the package config file using the following command:
$ php artisan vendor:publish --provider="MuhBayu\Fcm\FcmServiceProvider"
Register the provider in your bootstrap app file boostrap/app.php
Add the following line in the "Register Service Providers" section at the bottom of the file:
$app->register(MuhBayu\Fcm\FcmServiceProvider::class);
In your .env
file, add the server key and the secret key for the Firebase Cloud Messaging:
FCM_LEGACY_KEY=<your_server_Key>
FCM_SENDER_ID=<your_sender_id>
The following use statements are required for the examples below:
use MuhBayu\Fcm;
// if you want to send multiple $recipients token must an array
Fcm::to($recipients)->notification([
'title' => 'Title Message',
'body' => 'This is a body message of FCM',
'click_action' => 'http://yourdomain.com', // optional
'icon' => 'your_icon', //optional
])->send();
If You want to send a FCM to topic, use method
->topic('/topic/name')
If you want to send a FCM with data & notification parameter, you must use extra method :
Fcm::to($recipients)->notification([
// ...
])->extra([
'name' => 'Name Data',
'data' => 'Data test',
])->send();
fcm()->send($notification, $data);