2017 © Pedro Peláez
 

project the-laravel-fcm-channel

The Laravel FCM Channel

image

yusefarianpour/the-laravel-fcm-channel

The Laravel FCM Channel

  • Tuesday, May 1, 2018
  • by yusefarianpour
  • Repository
  • 1 Watchers
  • 0 Stars
  • 52 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 12 Versions
  • 11 % Grown

The README.md

The Laravel FCM Channel

The Laravel Firebase Cloud Messaging(FCM) Notification Channel, (*1)

Use this package to send push notifications via Laravel to Firebase Cloud Messaging. Laravel 5.3+ required., (*2)

Install

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

``` bash composer require journalctl/laravel-to-fcm, (*4)


Add your Firebase API Key to `config/services.php` ```php 'fcm' => [ 'key' => 'Your Firebase Cloud Messaging token', ],

Example Usage

Use Artisan to create a notification:, (*5)

php artisan make:notification SomeNotification

Return [fcm] in the public function via($notifiable) method of your notification:, (*6)

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

Or :, (*7)

use Journalctl\Channels\FirebaseChannel;

...

public function via($notifiable)
{
    return [FirebaseChannel::class];
}

Add the method public function toFcm($notifiable) to your notification, and return an instance of FirebaseMessage:, (*8)

use Journalctl\Channels\FirebaseChannel;
use Journalctl\Channels\FirebaseMessage;

...

public function toFcm($notifiable)
{
    $message = new FirebaseMessage();

    $message
        ->title('Foo')  // Required
        ->body('Bar')   // Required
        ->sound()   // Optional
        ->icon()   // Optional
        ->clickAction();    // Optional

    $message->data([
        'param1' => 'baz' // Optional
    ])->priority(FirebaseMessage::PRIORITY_HIGH); // Optional - Default is 'normal'.

    return $message;
}

When sending to specific device, make sure your notifiable entity has routeNotificationForFcm method defined:, (*9)

/**
 * Route notifications for the Firebase Cloud Messaging channel.
 *
 * @return string
 */
public function routeNotificationForFcm()
{
    return $this->device_token;
}

License

The "The Laravel FCM Channel" is open-sourced software licensed under the MIT license., (*10)

The Versions

01/05 2018

dev-master

9999999-dev

The Laravel FCM Channel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yusef Arianpour

laravel firebase channel fcm

27/02 2018

dev-yusef

dev-yusef

The Laravel FCM Channel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yusef Arianpour

laravel firebase channel fcm

27/02 2018

V2.1.4

2.1.4.0

The Laravel FCM Channel

  Sources   Download

MIT

The Requires

 

by Yusef Arianpour

laravel firebase channel fcm

28/01 2018

V2.1.3

2.1.3.0

The Laravel FCM Channel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yusef Arianpour

laravel firebase fcm

28/01 2018

V2.1.2

2.1.2.0

The Laravel FCM Channel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yusef Arianpour

laravel firebase fcm

28/01 2018

V2.1.1

2.1.1.0

The Laravel FCM Channel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yusef Arianpour

laravel firebase fcm

28/01 2018

V2.1.0

2.1.0.0

The Laravel FCM Channel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yusef Arianpour

laravel firebase fcm

15/11 2017

V2.0.2

2.0.2.0

The Laravel FCM Channel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yusef Arianpour

15/11 2017

dev-stable

dev-stable

The Laravel FCM Channel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yusef Arianpour

15/11 2017

V2.0.1

2.0.1.0

The Laravel FCM Channel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yusef Arianpour

13/10 2017

V1.0.8

1.0.8.0

The Laravel FCM Channel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yusef Arianpour

12/10 2017

V1.0.7

1.0.7.0

The Laravel FCM Channel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yusef Arianpour