Skip to content
Send Pusher API Notifications with Laravel notifications system.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Pusher API Notifications

Latest Version on Packagist Software License Build Status StyleCI Quality Score Code Coverage Total Downloads

This package makes it easy to send notifications using Pusher API Messages (like shown below) with Laravel 5.3 or greater.



Require the package:

$ composer require andreshg112/pusher-api-notifications

Setting up the Pusher API Notifications service

This package requires pusher/pusher-http-laravel ^4.2, so after installing this, you have to configure it.

If your using Laravel ^5.5, don't worry about adding the service provider to your config/app.php file because this package uses Laravel Package Discovery. If don't, you have to add it:

'providers' => [
    // ...,


This is a third-party Laravel Notification Package, so you should know how to use Notifications in Laravel before using this. Docs can be found here:

In your notification, add the PusherApiChannel to the via() function:

use Andreshg112\PusherApiNotifications\PusherApiChannel;

public function via($notifiable)
    return [PusherApiChannel::class];

Then, create a method called toApiNotification() in your notification:

use Andreshg112\PusherApiNotifications\PusherApiMessage;

public function toApiNotification($notifiable)
    return (new PusherApiMessage)

    // or

    return new PusherApiMessage($channelName, $eventName, $data, $socketId, $debug, $alreadyEncoded);

Available Message methods

  • channels($channelName): array or string of channel name(s).
  • event($eventName): the name of the event for the Pusher message.
  • data($data): array, string or something that can be corverted to JSON. It's the body of the Pusher message.
  • socketId($socketId): [optional] socketId of Pusher.
  • debug($debug): [optional] boolean that tells Pusher if you're debugging.
  • alreadyEncoded($alreadyEncoded): [optional] If the data is already encoded and you don't want Pusher to convert it, set this to true.

These parameters are the same received by Pusher::trigger() method.


Please see CHANGELOG for more information what has changed recently.


$ composer test


If you discover any security related issues, please email instead of using the issue tracker.


Please see CONTRIBUTING for details.



The MIT License (MIT). Please see License File for more information.

You can’t perform that action at this time.