besanek / laravel-firebase-notifications
Thin layer for integrate Firebase Messaging as Laravel Notifications
Installs: 36 407
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
pkg:composer/besanek/laravel-firebase-notifications
Requires
- php: ^8.0
 - ext-json: *
 - illuminate/notifications: ^10.0|^11.0|^12.0
 - illuminate/support: ^10.0|^11.0|^12.0
 - kreait/laravel-firebase: ^5.1|^6.0
 
Requires (Dev)
- mockery/mockery: ^1.4.2
 - orchestra/testbench: ^8.0|^9.0|^10.0
 - phpunit/phpunit: ^9.0|^10.0|^11.0
 
README
Thin layer for integrate Firebase Messaging as Laravel Notifications
Requirement
- PHP >= 8.1
 - Laravel = 10.x
 
Installing
$ composer require "besanek/laravel-firebase-notifications"
This is all, thanks to the Package Autodiscover.
Setup
Please follow configuration guide of kreait/laravel-firebase
Basic Usage
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.