2017 © Pedro Peláez
 

library laravel-firebase

Laravel FCM (Firebase Cloud Messaging) Notification Channel

image

liliom/laravel-firebase

Laravel FCM (Firebase Cloud Messaging) Notification Channel

  • Monday, February 26, 2018
  • by LiliomLab
  • Repository
  • 1 Watchers
  • 7 Stars
  • 659 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 2 Open issues
  • 3 Versions
  • 64 % Grown

The README.md

laravel-firebase

This package makes it easy to send notifications using Firebase Cloud Messaging (FCM) with Laravel Notification Channel., (*1)

Installation

This package can be installed through Composer., (*2)

``` bash composer require liliom/laravel-firebase, (*3)


If you don't use Laravel 5.5+ you have to add the service provider manually ```php // config/app.php 'providers' => [ ... Liliom\Firebase\FirebaseServiceProvider::class, ... ];

Now add you Firebase API Key in config/services.php., (*4)

return [
    ....
    'firebase' => [
        'key' => ''
    ],
    ....
];

Usage

Les's create a notification using artisan commend:, (*5)

php artisan make:notification FirebaseNotification

Now you can use firebase channel in your vie() mothod., (*6)

public function via($notifiable)
{
    return ['firebase'];
}

Add a pubilc method toFirebase($notifiable) to your notification class, and return an instance of FirebaseMessage:, (*7)

public function toFirebase($notifiable)
{
    return (new \Liliom\Firebase\FirebaseMessage)
        ->notification([
            'title' => 'Notification title',
            'body' => 'Notification body',
            'sound' => '', // Optional
        'icon' => '', // Optional
        'click_action' => '' // Optional
        ])
        ->setData([
        'param' => 'zxy' // Optional
    ])
    ->setPriority('high'); // Default is 'normal'
}

Available methods:

  • setData: To Set data.
  • setPriority: To Set priority.
  • setTimeToLive: To Set time_to_live.
  • setCollapseKey: To Set collapse_key.
  • setNotification: To Set notification.
  • setCondition: To Set condition.
  • setContentAvailable: To Set content_available.
  • setMutableContent: To Set mutable_content.
  • setPackageName: To Set restricted_package_name.

When sending to specific device(s), make sure your notifiable entity has routeNotificationForFirebase method defined:, (*8)

Note: You can send to many devices by return an array of tokens., (*9)

/**
 * Route notifications for Firebase channel.
 *
 * @return string|array
 */
public function routeNotificationForFirebase()
{
    return $this->device_tokens;
}

License

The MIT License (MIT). Please see License File for more information., (*10)

The Versions

26/02 2018

dev-master

9999999-dev

Laravel FCM (Firebase Cloud Messaging) Notification Channel

  Sources   Download

MIT

The Requires

 

by Hussam Abd

laravel notification firebase channel fcm notification-channel

26/02 2018

v1.0.1

1.0.1.0

Laravel FCM (Firebase Cloud Messaging) Notification Channel

  Sources   Download

MIT

The Requires

 

by Hussam Abd

laravel notification firebase channel fcm notification-channel

12/08 2017

v1.0.0

1.0.0.0

Laravel FCM (Firebase Cloud Messaging) Notification Channel

  Sources   Download

MIT

The Requires

 

by Hussam Abd

laravel notification firebase channel fcm notification-channel