Package Data | |
---|---|
Maintainer Username: | laravel-notification-channels |
Maintainer Contact: | alex@plekhanov.dev (Alex Plekhanov) |
Package Create Date: | 2016-08-12 |
Package Last Update: | 2024-06-19 |
Home Page: | https://laravel-notification-channels.com |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:16:05 |
Package Statistics | |
---|---|
Total Downloads: | 9,492 |
Monthly Downloads: | 40 |
Daily Downloads: | 1 |
Total Stars: | 14 |
Total Watchers: | 7 |
Total Forks: | 9 |
Total Open Issues: | 6 |
This package makes it easy to send notifications using Pushbullet with Laravel 5.3+.
To get the latest version of Pushbullet Notification channel for Laravel 5.3, simply require the project using Composer:
$ composer require laravel-notification-channels/pushbullet
Or you can manually update your require block and run composer update
if you choose so:
{
"require": {
"laravel-notification-channels/pushbullet": "^1.0"
}
}
You will also need to install guzzlehttp/guzzle
http client to send request to Pushbullet 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.
NotificationChannels\Pushbullet\PushbulletServiceProvider::class
In your pushbullet account go to Account settings page. Click Create Access Token
button and you will get access_token.
You need to put it to config/services.php
configuration file. You may copy the example configuration below to get started:
'pushbullet' => [
'access_token' => env('PUSHBULLET_ACCESS_TOKEN')
]
In order to send notifications to Pushbullet you need to specify recipient for each notifiable entity. There are currently 2 options: pushbullet email or device id of recipient.
To provide library with correct notification recipient you need to define routeNotificationForPushbullet
method on notifiable entity.
public function routeNotificationForPushbullet()
{
return new \NotificationChannels\Pushbullet\Targets\Email($this->email);
}
public function routeNotificationForPushbullet()
{
return new \NotificationChannels\Pushbullet\Targets\Device($this->pushbullet_device_id);
}
public function routeNotificationForPushbullet()
{
return new \NotificationChannels\Pushbullet\Targets\Channel($this->channel_tag);
}
via
MethodOn notification entity just add \NotificationChannels\Pushbullet\PushbulletChannel::class
item to array that is returned from via
method.
toPushbullet
MethodIn your notification class you also should define toPushbullet
method which will return instance of \NotificationChannels\Pushbullet\PushbulletMessage
.
/**
* Get the pushbullet representation of the notification.
*
* @param mixed $notifiable
* @return \NotificationChannels\Pushbullet\PushbulletMessage
*/
public function toPushbullet($notifiable)
{
$url = url('/invoice/' . $this->invoice->id);
return PushbulletMessage::create('Thank you for using our application!')
->link()
->title('One of your invoices has been paid!')
->url($url);
}
note()
: set notification type to note (title and message for notification are available)link()
: set notification type to link (title, message and url are available)title($title)
: (string) set notification titlemessage($message)
: (string) set notification messageurl($url)
: (string) set notification url (will be in notification if type is link
)Please see CHANGELOG for more information what has changed recently.
$ composer test
If you discover any security related issues, please email themsaid@gmail.com instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.