idstack / laravel-fcm
Package to send Firebase notification cross Laravel Application
1.0.0
2017-11-18 15:07 UTC
Requires
- php: >=5.4.0
- illuminate/support: ~5.0
This package is not auto-updated.
Last update: 2024-04-28 02:58:22 UTC
README
Simple package for using FCM as Push Notification. With multiple token or device ID and send with topics.
Installation
You can pull the package via composer :
$ composer require idstack/laravel-fcm
Register the service provider :
'Providers' => [ ... Idstack\Fcm\FcmServiceProvider::class, ]
Optional using facade:
'aliases' => [ ... 'Fcm' => Idstack\Fcm\Facades\Fcm::class, ];
Publish the config file to define your server key :
php artisan vendor:publish --provider="Idstack\Fcm\FcmServiceProvider"
This is the contents of the published file:
return [ /** * Insert your FCM Server Key Here * Or you can add in env file with FCM_SERVER_KEY variable */ 'fcm_server_key' => env('FCM_SERVER_KEY','') ];
Usage
This sample usage for sending notification to any devices with several information like title and body notification :
fcm() ->data([ 'title' => 'Test FCM', 'body' => 'This is a test of FCM', ]) ->to($recipients); // $recipients must an array
This sample usage for sending notification using topics with several information like title and body notification :
fcm() ->data([ 'title' => 'Test FCM', 'body' => 'This is a test of FCM', ]) ->toTopics($recipients); // $recipients must an array