laravel-notification-channels/pushover
Composer 安装命令:
composer require laravel-notification-channels/pushover
包简介
Pushover notifications for Laravel.
README 文档
README
This package makes it easy to send Pushover notifications with Laravel Notifications.
Contents
Installation
You can install the package via composer:
composer require laravel-notification-channels/pushover
Support Policy
This package supports various versions of Laravel and PHP with different releases. Choose the correct package version for your project. Please note that older versions of this package are no longer being updated.
| Package Version | Laravel Version | PHP Version | Status |
|---|---|---|---|
| 3.x | 8 - 10 | 8.0 - 8.3 | EOL |
| 4.x | 8 - 12 | 8.1 - 8.4 | Security patches only |
| 5.x | 11 - 13 | 8.2 - 8.5 | Active |
Setting up your Pushover account
To start sending messages via Pushover, you have to register an application. Add the generated Pushover application token to the services config file:
// config/services.php 'pushover' => [ 'token' => env('YOUR_APPLICATION_TOKEN'), ],
Usage
Now you can use the channel in your via() method inside the notification as well as send a push notification:
use NotificationChannels\Pushover\PushoverChannel; use NotificationChannels\Pushover\PushoverMessage; use Illuminate\Notifications\Notification; class AccountApproved extends Notification { public function via($notifiable) { return [PushoverChannel::class]; } public function toPushover($notifiable) { return PushoverMessage::create('The invoice has been paid.') ->title('Invoice paid') ->sound('incoming') ->lowPriority() ->url('http://example.com/invoices', 'Go to your invoices'); } }
To send Pushover notifications to the notifiable entity, add the routeNotificationForPushover method to that model.
Usually, this is the User model. The pushover_key could be a database field and editable by the user itself.
public function routeNotificationForPushover() { return $this->pushover_key; }
Advanced usage and configuration
If you want to specify specific devices, you can return a PushoverReceiver object.
public function routeNotificationForPushover() { return PushoverReceiver::withUserKey('pushover-key') ->toDevice('iphone') ->toDevice('desktop') // or, if you prefer: ->toDevice(['iphone', 'desktop']); }
If you want to (dynamically) overrule the application token from the services config, e.g. because each user holds their
own application token, return a PushoverReceiver object like this:
public function routeNotificationForPushover() { return PushoverReceiver::withUserKey('pushover-key') ->withApplicationToken('app-token'); }
You can also send a message to a Pushover group:
public function routeNotificationForPushover() { return PushoverReceiver::withGroupKey('pushover-group-key'); }
Available Message methods
| Method | Description |
|---|---|
content($message) |
Accepts a string value for the message text. |
html() |
Sets the message type to HTML. |
monospace() |
Sets the message type to monospace. |
plain() |
Sets the message type to plain text, this is the default. |
title($title) |
Accepts a string value for the message title. |
time($timestamp) |
Accepts either a Carbon object or a UNIX timestamp. |
url($url[, $title]) |
Accepts a string value for a supplementary url and an optional string value for the title of the url. |
sound($sound) |
Accepts a string value for the notification sound. |
image($image) |
Accepts a string value for the image location (either full or relative server path or a URL). If there is any error with the file (too big, not an image) it will silently send the message without the image attachment. |
priority($priority[, $retryTimeout, $expireAfter]) |
Accepts an integer value for the priority and, when the priority is set to emergency, also an integer value for the retry timeout and expiry time (in seconds). Priority values are available as constants |
lowestPriority() |
Sets the priority to the lowest priority. |
lowPriority() |
Sets the priority to low. |
normalPriority() |
Sets the priority to normal. |
highPriority() |
Sets the priority to high. |
emergencyPriority($retryTimeout, $expireAfter) |
Sets the priority to emergency and accepts integer values for the retry timeout and expiry time (in seconds). |
callback($callbackUrl) |
Sets a publicly-accessible URL that Pushover will send a request to when the user has acknowledged your notification for an emergency notification. |
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
composer test
Security
If you discover any security related issues, please email mail@casperboone.nl instead of using the issue tracker, or submit a vulnerability report using GitHub Security Advisories for this package.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
laravel-notification-channels/pushover 适用场景与选型建议
laravel-notification-channels/pushover 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 175.76k 次下载、GitHub Stars 达 60, 最近一次更新时间为 2016 年 08 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 laravel-notification-channels/pushover 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 laravel-notification-channels/pushover 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 175.76k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 61
- 点击次数: 21
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-12