Thin layer for integrate Firebase Messaging as Laravel Notifications
besanek/laravel-firebase-notifications is a Laravel package for thin layer for integrate firebase messaging as laravel notifications.
It currently has 0 GitHub stars and 40.380 downloads on Packagist (latest version v5.1.0).
Install it with composer require besanek/laravel-firebase-notifications.
Discover more Laravel packages by besanek
or browse all Laravel packages to compare alternatives.
Last updated
Thin layer for integrate Firebase Messaging as Laravel Notifications
$ composer require "besanek/laravel-firebase-notifications"
This is all, thanks to the Package Autodiscover.
Please follow configuration guide of kreait/laravel-firebase
Add new method routeNotificationForFirebase to your notifiable entity, witch returns device id.
/**
* It could be one device
*/
public function routeNotificationForFirebase()
{
return $this->device_id;
}
/**
* Or you can return array for multicast
*/
public function routeNotificationForFirebase()
{
return $this->devices()->get()->pluck('id');
}
In Notification entity you should add firebase to via() method.
public function via(): array
{
return ['firebase', /* 'email', 'database', 'etc...'*/];
}
And you can construct CloudMessage into toFirebase() method.
public function toFirebase(): Messaging\CloudMessage
$notification = Messaging\Notification::create('I <3 laravel', 'It is true');
return Messaging\CloudMessage::new()->withNotification($notificatin);
}
Please look into the official PHP SDK documentation for the full use of all possibilities.