azi / laravel-fcm-channel
Firebase Cloud Messages 通知驱动
0.2
2018-01-04 14:25 UTC
Requires
- php: >=5.5.9
- brozot/laravel-fcm: ^1.2
- illuminate/notifications: ~5.3
- illuminate/queue: ~5.1
- illuminate/support: ~5.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ~1.12.2
- mockery/mockery: ^1.0
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2024-09-25 10:34:15 UTC
README
本包使用 Firebase Cloud Messaging (FCM) (https://firebase.google.com/docs/cloud-messaging/) 来发送通知,使 Laravel 5.3 的使用变得更加容易。本包基于 brozot/laravel-fcm,因此请阅读该文档以获取更多信息。
内容
安装
您可以通过 composer 安装此包
composer require enniel/laravel-fcm-notification-channel:1.*
直接在您的应用程序配置文件 config/app.php 中注册提供者
'providers' => [ // ... NotificationChannels\FCM\ServiceProvider::class ]
用法
现在您可以在通知内部的 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
致谢
支持
遇到问题?请提出问题!
许可证
The MIT License (MIT)。更多信息请参阅 许可证文件。