nean / laravel-fcm-notification-channel
Firebase Cloud Messages Notification Driver
Package info
github.com/nean/laravel-fcm-notification-channel
pkg:composer/nean/laravel-fcm-notification-channel
Requires
- php: ^7.1
- brozot/laravel-fcm: ^1.3
- illuminate/notifications: ^5.8||^6.0
- illuminate/queue: ^5.8||^6.0
- illuminate/support: ^5.8||^6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ~2.16
- mockery/mockery: ^1.2
- phpunit/phpunit: ^7||^8
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
This package makes it easy to send notifications using Firebase Cloud Messaging (FCM) with Laravel 5.8 and above. This package is based on brozot/laravel-fcm, so please read that documentation for more information.
Contents
Installation
You can install this package via composer:
composer require nean/laravel-fcm-notification-channel:^2
Usage
Now you can use the channel in your via() method inside the notification:
use NotificationChannels\FCM\FCMMessage; use Illuminate\Notifications\Notification; class ExampleNotification extends Notification { public function via($notifiable) { return ['fcm']; } public function toFCM($notifiable) { return (new FCMMessage()) ->notification([ 'title' => 'Notification title', 'body' => 'Notification body', ]); } }
Available message types:
FCMMessage: Send notifications to device(s).FCMMessageTopic: Send notifications to topic(s).FCMMessageGroup: Send notifications to group(s).
In order for your notice to know who to send messages, you must add routeNotificationForFCM method to your notification model.
Available message methods
data(): Notification data.array|LaravelFCM\Message\PayloadData|LaravelFCM\Message\PayloadDataBuilderoptions(): Notification options.array|LaravelFCM\Message\Options|LaravelFCM\Message\OptionsBuildernotification(): Notification content.array|LaravelFCM\Message\PayloadNotification|LaravelFCM\Message\PayloadNotificationBuilder
Proxy methods. See brozot/laravel-fcm for more information about this methods.
setDryRunsetPrioritysetTimeToLivesetCollapseKeysetDelayWhileIdlesetMutableContentsetContentAvailablesetRestrictedPackageNameisDryRungetPrioritygetTimeToLivegetCollapseKeyisDelayWhileIdleisMutableContentisContentAvailablegetRestrictedPackageNamesetTagsetBodysetIconsetTitlesetSoundsetBadgesetColorsetChannelIdsetClickActionsetBodyLocationKeysetBodyLocationArgssetTitleLocationKeysetTitleLocationArgsgetTaggetBodygetIcongetTitlegetSoundgetBadgegetColorgetChannelIdgetClickActiongetBodyLocationKeygetBodyLocationArgsgetTitleLocationKeygetTitleLocationArgs
Testing
$ composer test
Credits
Support
Having trouble? Open an issue!
License
The MIT License (MIT). Please see License File for more information.