Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/midnite81/prowl
A PHP wrapper for using the Prowl API, with a Laravel 5 service provider for integration with Laravel
https://github.com/midnite81/prowl
laravel prowl prowlapp push-notifications
Last synced: about 2 months ago
JSON representation
A PHP wrapper for using the Prowl API, with a Laravel 5 service provider for integration with Laravel
- Host: GitHub
- URL: https://github.com/midnite81/prowl
- Owner: midnite81
- Created: 2016-04-22T08:08:15.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-02-05T10:27:53.000Z (almost 2 years ago)
- Last Synced: 2024-06-18T11:59:51.487Z (6 months ago)
- Topics: laravel, prowl, prowlapp, push-notifications
- Language: PHP
- Homepage: https://midnite.uk/github/prowl
- Size: 83 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme-laravel.md
Awesome Lists containing this project
README
# Prowl
[![Latest Stable Version](https://poser.pugx.org/midnite81/prowl/version)](https://packagist.org/packages/midnite81/prowl) [![Total Downloads](https://poser.pugx.org/midnite81/prowl/downloads)](https://packagist.org/packages/midnite81/prowl) [![Latest Unstable Version](https://poser.pugx.org/midnite81/prowl/v/unstable)](https://packagist.org/packages/midnite81/prowl) [![License](https://poser.pugx.org/midnite81/prowl/license.svg)](https://packagist.org/packages/midnite81/prowl) [![Build](https://travis-ci.org/midnite81/prowl.svg?branch=master)](https://travis-ci.org/midnite81/prowl) [![Coverage Status](https://coveralls.io/repos/github/midnite81/prowl/badge.svg?branch=master)](https://coveralls.io/github/midnite81/prowl?branch=master)# Laravel 5 Integration
To integrate this package more fully with Laravel 5, add the Prowl service provider to the list of service providers
in `app/config/app.php`.```php
'providers' => [
Midnite81\Prowl\ProwlServiceProvider::class
];
```
Add the `Prowl` facade to your aliases array.```php
'aliases' => [
'Prowl' => Midnite81\Prowl\Facades\Prowl::class,
];
```
Publish the Prowl config file using
```sh
php artisan vendor:publish --provider="Midnite81\Prowl\ProwlServiceProvider"
```## Configuration File
Once you have published the config files, you will find a `prowl.php` file in the `config` folder. You should
look through these settings and update these where necessary.You shouldn't need to update the api url, but it's available in the configuration should you need to.
## Methods
There are four main methods on the Prowl class, which identify the main four api calls you can make.
|Api Method |Prowl Method |Description |
|----------------|----------------------------------------------|---------------------------------------------------------------------|
|add | $prowl->add(Notification $notification) | Sends a push notification to one or more devices |
|verify | $prowl->verify($apiKey, $providerKey) | Verifies the api key is valid |
|retrieve/token | $prowl->retrieveToken($providerKey) | Get a registration token for use in retrieve/apikey |
|retrieve/apikey | $prowl->retrieveApiKey($providerKey, $token) | Get an API Key from a registration token received in retrieve/token |To understand what each of these api calls does, you should check out the documentation at
[https://www.prowlapp.com/api.php](https://www.prowlapp.com/api.php)## Example Usage
The laravel integration is not too dissimilar from the standard implementation but it takes care of all of the
configuration issues as those are stored in the `config/prowl.php` file.You can use the Facade if you want to, but in the examples I provide I'll inject them as it's a little more efficient
to do it that way.```php
createMessage()
->setApiKeys('iphone') // as defined in the 'keys' section of the prowl config
->setPriority(Priority::HIGH) // or you can specify a number between -2 to 2
->setEvent('The Event')
->setDescription('The Description')
->setApplication('The Application')
->setMessage('The Message')
->send();
}
/**
* Option two create the message and then send through prowl
*/
public function optionTwo(Midnite81\Prowl\Contracts\Prowl $prowl) {
$msg = $prowl->createMessage();
$msg->setApiKeys('iphone') // as defined in the 'keys' section of the prowl config
->setPriority(Priority::HIGH) // or you can specify a number between -2 to 2
->setEvent('The Event')
->setDescription('The Description')
->setApplication('The Application')
->setMessage('The Message');
$pushNotification = $prowl->add($msg);
}
}
```The `setApiKeys` method can take either an array of api keys (or config'ed aliases) or a single string. You can call the
method any number of times you want and it will continue to add api keys to the `Notification` object.For your convenience, the add method has been aliased to include `send` and `push`; therefore you can just as easily
call `$prowl->push($msg);` or `$prowl->send($msg);`## Response
Unless there are any Exceptions thrown you will receive a `Response` object back. For more information on the response
object please view [readme-response.md](readme-response.md)