PHPackages                             laravel-notification-channels/pubnub - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. laravel-notification-channels/pubnub

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

laravel-notification-channels/pubnub
====================================

PubNub Notifications Channel for Laravel

1.1.0(6y ago)102.1k5[1 PRs](https://github.com/laravel-notification-channels/pubnub/pulls)MITPHPPHP &gt;=7.1CI failing

Since Aug 19Pushed 4y ago2 watchersCompare

[ Source](https://github.com/laravel-notification-channels/pubnub)[ Packagist](https://packagist.org/packages/laravel-notification-channels/pubnub)[ Docs](https://github.com/laravel-notification-channels/pubnub)[ RSS](/packages/laravel-notification-channels-pubnub/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (6)Versions (3)Used By (0)

PubNub Notifications Channel for Laravel
========================================

[](#pubnub-notifications-channel-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4cb38e5b22ed25d747c22d204489189d9111ee465752784c6543a098bec8b5e4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f7075626e75622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-notification-channels/pubnub)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/2194874e67d0dae964847dbed0929ea4ede8d75aa0cfb2ffd99b5328ada3641a/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f7075626e75622f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/laravel-notification-channels/pubnub)[![StyleCI](https://camo.githubusercontent.com/0bb8ee0b86ebabb59ad8880a7171ca8fb1b63763f30205e89a6aa933d59634dd/68747470733a2f2f7374796c6563692e696f2f7265706f732f36353835343232352f736869656c64)](https://styleci.io/repos/65854225)[![Quality Score](https://camo.githubusercontent.com/ed564746b23e72044667249740aef42ad47b3bfbd003c102283680f04319cee2/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f7075626e75622e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/laravel-notification-channels/pubnub)[![Code Coverage](https://camo.githubusercontent.com/8986f9c82bc138eb08b32c01d0a14451f6d81ea6469d55a71505df6d7cc530f2/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f7075626e75622f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/laravel-notification-channels/pubnub/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/19be7de8ce1b9ae61d0d6dfda9479212583c32d80dca8286f098aeddd97cc51f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f7075626e75622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-notification-channels/pubnub)

PubNub Notifications Channel for Laravel 5.5+ &amp; 6.0. This channel allows you to send message payloads as well as push notifications to iOS, Android and Windows using PubNub.

Contents
--------

[](#contents)

- [Installation](#installation)
    - [Setting up the PubNub service](#setting-up-the-PubNub-service)
- [Usage](#usage)
    - [Available Message methods](#available-message-methods)
- [Changelog](#changelog)
- [Testing](#testing)
- [Security](#security)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

Installation
------------

[](#installation)

```
composer require laravel-notification-channels/pubnub
```

Add the service provider to your `config/app.php`

```
// config/app.php
'providers' => [
    ...
    NotificationChannels\Pubnub\PubnubServiceProvider::class,
],
```

### Setting up the PubNub service

[](#setting-up-the-pubnub-service)

Add your PubNub Publish Key, Subscribe Key and Secret Key to your `config/services.php`

```
// config/services.php
...

'pubnub' => [
    'publish_key'   => env('PUBNUB_PUBLISH_KEY'),
    'subscribe_key' => env('PUBNUB_SUBSCRIBE_KEY'),
    'secret_key'    => env('PUBNUB_SECRET_KEY'),
],

...
```

Usage
-----

[](#usage)

```
use NotificationChannels\Pubnub\PubnubChannel;
use NotificationChannels\Pubnub\PubnubMessage;
use Illuminate\Notifications\Notification;

class InvoicePaid extends Notification
{
    public function via($notifiable)
    {
        return [PubnubChannel::class];
    }

    public function toPubnub($notifiable)
    {
        return (new PubnubMessage())
            ->channel('my_channel')
            ->title('My message title')
            ->body('My message body');
    }
}
```

Alternatively you may supply a channel specifically related to your notifiable by implementing the `routeNotificationForPubnub()` method.

```
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;

class User extends Model
{
    use Notifiable;

    public function routeNotificationForPubnub()
    {
        return $this->pubnub_channel;
    }
}
```

Sending a push notification. You may chain any of the `withiOS()`, `withAndroid()` and `withWindows()` methods to add push notifications to the message with each of the platforms.

```
use NotificationChannels\Pubnub\PubnubChannel;
use NotificationChannels\Pubnub\PubnubMessage;
use Illuminate\Notifications\Notification;

class InvoicePaid extends Notification
{
    public function via($notifiable)
    {
        return [PubnubChannel::class];
    }

    public function toPubnub($notifiable)
    {
        return (new PubnubMessage())
            ->channel('my_channel')
            ->title('Alert: Jon Doe Sent You A Message')
            ->body('Hi')
            ->withiOS(
                (new PubnubMessage())
                    ->sound('default')
                    ->badge(1)
            )
            ->withAndroid(
                (new PubnubMessage())
                    ->sound('notification')
                    ->icon('myicon')
            )
            ->withWindows(
                (new PubnubMessage())
                    ->type('toast')
                    ->delay(450);
            );
    }
}
```

### Available methods

[](#available-methods)

- `channel('')`: Specifies the channel the message should be sent to
- `title('')`: Sets the title of the message
- `body('')`: Sets the body of the message
- `storeInHistory(true)`: If the message should be stored in the Pubnub history
- `badge(1)`: Sets the number to display on the push notification's badge (iOS)
- `sound('')`: Sets the sound for the push notification (iOS, Android)
- `icon('')`: Sets the push notification icon (Android)
- `type('')`: Sets the type of push notification (Windows)
- `delay(450)`: Sets the delay in seconds for the push notification (Windows)
- `setData($key, $value)`: Adds any extra data to the payload you may need
- `setOption($key, $value)`: Sets any option to the push notification ([iOS](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/TheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH107-SW1), [Android](https://developers.google.com/cloud-messaging/http-server-ref#notification-payload-support), Windows)
- `withiOS(PubnubMessage $message)`: Sets the push notification for iOS
- `withAndroid(PubnubMessage $message)`: Sets the push notification for Android
- `withWindows(PubnubMessage $message)`: Sets the push notification for Windows

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Security
--------

[](#security)

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

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [iWader](https://github.com/iWader)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2412d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20937037?v=4)[Laravel Notification Channels](/maintainers/laravel-notification-channels)[@laravel-notification-channels](https://github.com/laravel-notification-channels)

---

Top Contributors

[![iWader](https://avatars.githubusercontent.com/u/2007548?v=4)](https://github.com/iWader "iWader (38 commits)")[![atymic](https://avatars.githubusercontent.com/u/50683531?v=4)](https://github.com/atymic "atymic (3 commits)")[![ziming](https://avatars.githubusercontent.com/u/679513?v=4)](https://github.com/ziming "ziming (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/laravel-notification-channels-pubnub/health.svg)

```
[![Health](https://phpackages.com/badges/laravel-notification-channels-pubnub/health.svg)](https://phpackages.com/packages/laravel-notification-channels-pubnub)
```

###  Alternatives

[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[laravel-notification-channels/telegram

Telegram Notifications Channel for Laravel

1.1k3.4M35](/packages/laravel-notification-channels-telegram)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[laravel-notification-channels/webpush

Web Push Notifications driver for Laravel.

7984.5M16](/packages/laravel-notification-channels-webpush)[laravel-notification-channels/fcm

FCM (Firebase Cloud Messaging) Notifications Driver for Laravel

5917.0M16](/packages/laravel-notification-channels-fcm)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
