laravel-notification-channels / pushover
Pushover notifications for Laravel.
Installs: 67 319
Dependents: 0
Suggesters: 0
Security: 0
Stars: 55
Watchers: 6
Forks: 31
Open Issues: 2
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.0.1
- illuminate/notifications: ^8.0 || ^9.0 || ^10.0 || ^11.0
- illuminate/support: ^8.0 || ^9.0 || ^10.0 || ^11.0
Requires (Dev)
- dms/phpunit-arraysubset-asserts: >=0.1.0
- mockery/mockery: ^1.3.1
- orchestra/testbench: ^8.0 || ^9.0
- phpunit/phpunit: ^9.3 || ^10.5
Suggests
- ext-exif: Required for image attachment support
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
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' => '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
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.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.