nean / laravel-fcm-notification-channel
Firebase云消息通知驱动
2.0.1
2020-02-18 11:29 UTC
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
README
本软件包使您能够使用Firebase云消息(FCM)通过Laravel 5.8及以上版本发送通知。本软件包基于 brozot/laravel-fcm,请阅读该文档以获取更多信息。
内容
安装
您可以通过composer安装此软件包
composer require nean/laravel-fcm-notification-channel:^2
使用方法
现在您可以在通知中的 via() 方法中使用此通道
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', ]); } }
可用的消息类型
FCMMessage:向设备(s)发送通知。FCMMessageTopic:向主题(s)发送通知。FCMMessageGroup:向组(s)发送通知。
为了使您的通知知道向谁发送消息,您必须将 routeNotificationForFCM 方法添加到您的通知模型中。
可用的消息方法
data():通知数据。array|LaravelFCM\Message\PayloadData|LaravelFCM\Message\PayloadDataBuilderoptions():通知选项。array|LaravelFCM\Message\Options|LaravelFCM\Message\OptionsBuildernotification():通知内容。array|LaravelFCM\Message\PayloadNotification|LaravelFCM\Message\PayloadNotificationBuilder
代理方法。有关这些方法的更多信息,请参阅 brozot/laravel-fcm。
setDryRunsetPrioritysetTimeToLivesetCollapseKeysetDelayWhileIdlesetMutableContentsetContentAvailablesetRestrictedPackageNameisDryRungetPrioritygetTimeToLivegetCollapseKeyisDelayWhileIdleisMutableContentisContentAvailablegetRestrictedPackageNamesetTagsetBodysetIconsetTitlesetSoundsetBadgesetColorsetChannelIdsetClickActionsetBodyLocationKeysetBodyLocationArgssetTitleLocationKeysetTitleLocationArgsgetTaggetBodygetIcongetTitlegetSoundgetBadgegetColorgetChannelIdgetClickActiongetBodyLocationKeygetBodyLocationArgsgetTitleLocationKeygetTitleLocationArgs
测试
$ composer test
致谢
支持
遇到问题?打开一个问题!
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。