Git Product home page Git Product logo

laravel-pushover's Introduction

A Pushover.net API implementation for Laravel 5

A simple, yet very powerful, package that helps you get started with sending push notifications to your iOS or Android device through the pushover.net service.

Content

Installation

To get the latest version of edwardkarlsson/laravel-pushover simply require it in your composer.json file.

composer require edwardkarlsson/laravel-pushover:dev-master

This package utilizes the autodiscovery features of Laravel so the installation will be a breeze.

Configuration

The only configuration you need to do is to add the following to your .env file

PUSHOVER_TOKEN=[enter your token here]
PUSHOVER_USER=[place this your user key here]

Usage

Send message

To send a notification, simply add this to your code:

$message = new PushoverMessage('My message');
$message->send();

Don't forget to import the class into your file: use Pushover\PushoverMessage;

Advanced usage:

$message = new PushoverMessage('My message');
        
$message
    ->sound('cashregister')
    ->url('http://example.com')
    ->urlTitle('ExampleSite')
    ->priority(1)
    ->device('my-main-device')
    ->send();

Get limits

To get your monthly limits, write the following:

$limitation = new PushoverLimitation();

$limitsResponse = $limitation->get();

echo $limitsResponse->limit();
echo $limitsResponse->remaining();
echo $limitsResponse->reset();

Get receipt

When a message with priority 2 is sent, you can get a receipt to check on the acknowledgment of the message.

$message = new PushoverMessage($this->faker->sentence, $this->faker->word);

$messageResponse = $message
    ->priority(2)
    ->retry(30)
    ->expire(120)
    ->send();

$receiptResponse = $messageResponse->receipt()->get();

// Available methods
$receiptResponse->acknowledged(); // returns boolean
$receiptResponse->acknowledgedAt(); // returns Carbon
$receiptResponse->acknowledgedBy(); // returns string
$receiptResponse->acknowledgedByDevice(); // returns string
$receiptResponse->lastDeliveredAt(); // returns Carbon
$receiptResponse->expired(); // returns boolean
$receiptResponse->expiresAt(); // returns Carbon
$receiptResponse->calledBack(); // returns boolean
$receiptResponse->calledBackAt(); // returns Carbon

License

Copyright (c) 2018 Edward Karlsson Licensed under the MIT license.

laravel-pushover's People

Watchers

Hugo Saldana avatar  avatar

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.