pendonl / laravel-notifications-channel-pushed
Laravel 5.3+ Notifications Pushed Driver
Requires
- php: >=5.6.4
- guzzlehttp/guzzle: ^6.2
- illuminate/notifications: ~5.3.0|~5.4.0|~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0
- illuminate/support: ~5.1.0|~5.2.0|~5.3.0|~5.4.0|~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0
Requires (Dev)
- mockery/mockery: ^0.9.5
- phpunit/phpunit: 5.*
This package is auto-updated.
Last update: 2024-11-23 08:06:50 UTC
README
This package makes it easy to send notifications using Pushed with Laravel 5.3+.
Contents
Installation
To get the latest version of Pushed Notification channel for Laravel 5.3, simply require the project using Composer:
$ composer require pendonl/laravel-notifications-channel-pushed
Or you can manually update your require block and run composer update
if you choose so:
{ "require": { "pendonl/laravel-notifications-channel-pushed": "^1.0" } }
You will also need to install guzzlehttp/guzzle
http client to send request to Pushed API.
If you use Laravel 5.5 or higher, you don't need the following step. If not, once package is installed, you need to register the service provider. Open up config/app.php
and add the following to the providers
key.
PendoNL\LaravelNotificationsChannelPushed\PushedServiceProvider::class
Setting up the Pushed service
Login to Pushed, create a new app or edit an existing one. Navigate to App Settings
and find the App Key and App Secret around the bottom of the page. You need to put it to config/services.php
configuration file. You may copy the example configuration below to get started:
'pushed' => [ 'app_key' => env('PUSHED_APP_KEY', ''), 'app_secret' => env('PUSHED_APP_SECRET', '') ]
Put these Environment keys in the .env file of your project
PUSHED_APP_KEY=
PUSHED_APP_SECRET=
Usage
First of, create or edit a Notification of your choice. In order to send notifications using this channel you have to specify a toPushed
method on your Notification.
The toPushed
Method
/** * Get the Pushed representation of the notification. * * @param mixed $notifiable * @return \PendoNL\LaravelNotificationsChannelPushed\PushedMessage */ public function toPushed($notifiable) { $url = url('/thanks'); return PushedMessage::create('Thank you for using our application!') ->setUrl($url) ->toApp(); }
Available Message methods
setUrl($url)
: (string) adds a URL action to the notificationtoApp()
: sends the notification to all users registered to your apptoChannel($alias)
: (string) sends the notification to a given channel aliastoUser($accessToken)
: (string) sends the notification to a user that registered to your app using OAuthtoPushedId($pushedId)
: (string) sends the notification directly to a user's Pushed ID
Testing
$ composer test
Security
If you discover any security related issues, please email joshua@pendo.nl instead of using the issue tracker.
Contributing
Please feel free to Fork this project and make improvements. Create a Pull request with sufficient information about what improvements or changes you've made.
Credits
License
The MIT License (MIT). Please see License File for more information.