carlcs / craft-pushovernotificationchannel
A Pushover notification channel for the Craft Notifications plugin
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:craft-plugin
Requires
- craftcms/cms: ^3.0.0-RC1
- rias/craft-notifications: ^1.0.6
README
A Pushover notification channel for the Craft Notifications plugin
Requirements
The plugin requires Craft CMS 3.0 or later, and the Craft Notifications plugin.
Installation
To install the plugin, follow these instructions.
- Open your terminal and go to your Craft project:
cd /path/to/project
- Then tell Composer to load the plugin:
composer require carlcs/craft-pushovernotificationchannel
- In the Control Panel, go to Settings → Plugins and click the “Install” button for Pushover Notification Channel.
Usage
To configure a notification to be sent via Pushover, make sure your via()
method on the Notification class returns a key with 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'); } }
The pushover
value in the via()
method can also be a PushoverReceiver
object.
This allows to specify devices, or to overrule the API Token set in the plugin settings.
return [ 'pushover' => PushoverReceiver::withUserKey('<PUSHOVER_USER_OR_GROUP_KEY>') ->toDevice('iphone') ->withApplicationToken('<PUSHOVER_API_TOKEN>');, ];