Looking to hire Laravel developers? Try LaraJobs

laravel-fcm maintained by idstack

Description
Package to send Firebase notification cross Laravel Application
Author
Last update
2017/11/18 16:38 (dev-master)
License
Links
Downloads
12

Comments
comments powered by Disqus

Simple Laravel FCM

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