This package makes it easy to send notifications using Pushed with Laravel 5.3+.
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
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=
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.
/**
* 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();
}
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
$ composer test
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
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.
The MIT License (MIT). Please see License File for more information.