enniel / laravel-fcm-notification-channel
Firebase云消息通知驱动
0.2.0
2018-01-15 10:03 UTC
Requires
- php: >=5.5.9
- brozot/laravel-fcm: ~1.2.5
- 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-06 04:11:53 UTC
README
此包使您能够通过Firebase云消息(FCM)轻松发送通知,适用于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
:向设备发送通知。FCMMessageTopic
:向主题发送通知。FCMMessageGroup
:向组发送通知。
为了使您的通知知道向谁发送消息,您必须将 routeNotificationForFCM
方法添加到您的通知模型中。
可用消息方法
data()
:通知数据。array
|LaravelFCM\Message\PayloadData
|LaravelFCM\Message\PayloadDataBuilder
options()
:通知选项。array
|LaravelFCM\Message\Options
|LaravelFCM\Message\OptionsBuilder
notification()
:通知内容。array
|LaravelFCM\Message\PayloadNotification
|LaravelFCM\Message\PayloadNotificationBuilder
代理方法。有关此方法的更多信息,请参阅brozot/laravel-fcm。
setDryRun
setPriority
setTimeToLive
setCollapseKey
setDelayWhileIdle
setMutableContent
setContentAvailable
setRestrictedPackageName
isDryRun
getPriority
getTimeToLive
getCollapseKey
isDelayWhileIdle
isMutableContent
isContentAvailable
getRestrictedPackageName
setTag
setBody
setIcon
setTitle
setSound
setBadge
setColor
setChannelId
setClickAction
setBodyLocationKey
setBodyLocationArgs
setTitleLocationKey
setTitleLocationArgs
getTag
getBody
getIcon
getTitle
getSound
getBadge
getColor
getChannelId
getClickAction
getBodyLocationKey
getBodyLocationArgs
getTitleLocationKey
getTitleLocationArgs
测试
$ composer test
致谢
支持
遇到问题?打开一个问题!
许可证
MIT许可证(MIT)。请参阅许可证文件以获取更多信息。