Laravel Notification Channels

News

October 23rd, 2019

Laravel Notification Channels

Laravel Notification Channels is a collection of custom notification drivers for Laravel. With roughly thirty-nine ready-to-use channels at the time of writing, this is likely the most extensive collection of notification plugins for any framework.

The notification channels GitHub organization is a centralized place for all of the different notification packages. However, individual packages might be maintained by various authors:

We aim to provide a curated selection of notification channels for use in your Laravel applications…If we don’t have a package for your desired service yet, read on for instructions on how to contribute!

If you have an idea for a notification channel, check out the skeleton repo for creating a new notification channel. Once you are ready to contribute your channel, open a pull request to laravel-notification-channels/channels. Authors get admin access to their channel repository and an invite to the Laravel Notification Channels GitHub organization.

Here’s a quick example of an account notification from the Apple Push Notification service (APNs) documentation:

use NotificationChannels\Apn\ApnChannel;
use NotificationChannels\Apn\ApnMessage;
use Illuminate\Notifications\Notification;
 
class AccountApproved extends Notification
{
public function via($notifiable)
{
return [ApnChannel::class]; // Make sure you use ‘ApnChannel::class’, not just ‘apn’
}
 
public function toApn($notifiable)
{
return ApnMessage::create()
->badge(1)
->title(‘Account approved’)
->body(“Your {$notifiable->service} account was approved!);
}
}

To learn more about the available channels, check out the official documentation. Each channel in the documentation has installation instructions and details on getting started.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.