carlcs/craft-pushovernotificationchannel

为Craft Notifications插件提供的Pushover通知通道

1.0.0 2018-03-09 08:11 UTC

This package is auto-updated.

Last update: 2024-09-20 04:39:03 UTC


README

Craft Notifications插件提供的Pushover通知通道

要求

此插件需要Craft CMS 3.0或更高版本,以及Craft Notifications插件。

安装

要安装插件,请按照以下说明操作。

  1. 打开您的终端并转到您的Craft项目
cd /path/to/project
  1. 然后告诉Composer加载插件
composer require carlcs/craft-pushovernotificationchannel
  1. 在控制面板中,转到设置 → 插件,并为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>');,
];

鸣谢

Laravel Notifications Channel - Pushover