PHP code example of carlcs / craft-pushovernotificationchannel
1. Go to this page and download the library: Download carlcs/craft-pushovernotificationchannel library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
carlcs / craft-pushovernotificationchannel example snippets
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');
}
}
return [
'pushover' => PushoverReceiver::withUserKey('<PUSHOVER_USER_OR_GROUP_KEY>')
->toDevice('iphone')
->withApplicationToken('<PUSHOVER_API_TOKEN>');,
];