carlcs / craft-pushovernotificationchannel
为Craft Notifications插件提供的Pushover通知通道
1.0.0
2018-03-09 08:11 UTC
Requires
- craftcms/cms: ^3.0.0-RC1
- rias/craft-notifications: ^1.0.6
README
为Craft Notifications插件提供的Pushover通知通道
要求
此插件需要Craft CMS 3.0或更高版本,以及Craft Notifications插件。
安装
要安装插件,请按照以下说明操作。
- 打开您的终端并转到您的Craft项目
cd /path/to/project
- 然后告诉Composer加载插件
composer require carlcs/craft-pushovernotificationchannel
- 在控制面板中,转到设置 → 插件,并为Pushover通知通道点击“安装”按钮。
使用方法
要配置通过Pushover发送的通知,请确保您的Notification类上的via()
方法返回一个包含pushover
键的键。
<?php namespace app\notifications; use carlcs\pushovernotificationchannel\models\PushoverMessage; use carlcs\pushovernotificationchannel\models\PushoverReceiver; use rias\notifications\models\Notification; class ElementSaved extends Notification { public function via() { return [ 'pushover' => '<PUSHOVER_USER_OR_GROUP_KEY>', ]; } public function toPushover($notifiable) { $element = $this->event->sender; return PushoverMessage::create("Element saved {$element->title}") ->sound('incoming') ->lowPriority() ->url($element->getUrl(), 'Go to element page'); } }
via()
方法中的pushover
值也可以是一个PushoverReceiver
对象。这允许指定设备或覆盖插件设置中设置的API令牌。
return [ 'pushover' => PushoverReceiver::withUserKey('<PUSHOVER_USER_OR_GROUP_KEY>') ->toDevice('iphone') ->withApplicationToken('<PUSHOVER_API_TOKEN>');, ];