GithubHelp home page GithubHelp logo

hxnk / pushover Goto Github PK

View Code? Open in Web Editor NEW

This project forked from laravel-notification-channels/pushover

0.0 1.0 0.0 53 KB

Pushover notifications channel for Laravel

Home Page: http://laravel-notification-channels.com

License: MIT License

PHP 100.00%

pushover's Introduction

Pushover notifications channel for Laravel

Latest Version on Packagist Software License Build Status StyleCI SensioLabsInsight Quality Score Code Coverage Total Downloads

This package makes it easy to send Pushover notifications with Laravel Notifications (included in Laravel 5.3 and higher).

Contents

Installation

You can install the package via composer:

composer require laravel-notification-channels/pushover

For Laravel 5.4 or lower, you must add the service provider to the app config:

// config/app.php
'providers' => [
    ...
    NotificationChannels\Pushover\PushoverServiceProvider::class,
],

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');
    }
}

Make sure there is a routeNotificationForPushover method on your notifiable model, for instance:

...
public function routeNotificationForPushover()
{
    return $this->pushover_key;
}

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']);
}

You can also send a message to a Pushover group:

...
public function routeNotificationForPushover() {
    return PushoverReceiver::withGroupKey('pushover-group-key');
}

Available Message methods

Please note that only the message content is mandatory, all other methods are optional. The message content can be set via content(''), via the create method PushoverMessage::create('') or via the constructor new PushoverMessage('').

  • content($message): Accepts a string value for the message text.
  • title($title): Accepts a string value for the message title.
  • time($timestamp): Accepts either a Carbon object or an 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.
  • 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: LOWEST_PRIORITY, LOW_PRIORITY, NORMAL_PRIORITY and EMERGENCY_PRIORITY.
  • 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).

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email [email protected] 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.