PHPackages                             dptsi/laravel-push-notification - 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. dptsi/laravel-push-notification

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

dptsi/laravel-push-notification
===============================

Laravel Firebase Cloud Messaging.

01PHP

Since Feb 1Pushed 3y ago6 watchersCompare

[ Source](https://github.com/dptsi/laravel-push-notification)[ Packagist](https://packagist.org/packages/dptsi/laravel-push-notification)[ RSS](/packages/dptsi-laravel-push-notification/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-push-notification
=========================

[](#laravel-push-notification)

### Introduction

[](#introduction)

A package that offers you to send push notifications or custom messages via Firebase in Laravel.

Firebase Cloud Messaging (FCM) is a cross-platform messaging solution that lets you reliably deliver messages at no cost.

For use cases such as instant messaging, a message can transfer a payload of up to 4KB to a client app.

### Installation

[](#installation)

Follow the steps below to install the package.

**Composer**

```
composer require dptsi/laravel-push-notification

```

**Copy Config**

Run `php artisan vendor:publish --provider="Dptsi\PushNotification\Providers\PushNotificationServiceProvider"` to publish the `pushnotification.php` config file.

**Get Athentication Key**

Get Authentication Key from

**Configure pushnotification.php as needed**

```
'authentication_key' => '{AUTHENTICATION_KEY}'

```

### Usage

[](#usage)

Follow the steps below to find how to use the package.

Example usage in **Controller/Service** or any class:

```
use Dptsi\PushNotification\Facades\PushNotification;

class MyController
{
    private $deviceTokens =['{TOKEN_1}', '{TOKEN_2}'];

    public function sendNotification()
    {
        return PushNotification::withTitle('Test Title')
            ->withBody('Test body')
            ->withImage('https://firebase.google.com/images/social.png')
            ->withIcon('https://seeklogo.com/images/F/firebase-logo-402F407EE0-seeklogo.com.png')
            ->withSound('default')
            ->withClickAction('https://www.google.com')
            ->withPriority('high')
            ->withAdditionalData([
                'color' => '#rrggbb',
                'badge' => 0,
            ])
            ->sendNotification($this->deviceTokens);

        // Or
        return PushNotification::fromArray(['title' => 'Test Title', 'body' => 'Test body'])->sendNotification($this->deviceTokens);
    }

    public function sendMessage()
    {
        return PushNotification::withTitle('Test Title')
            ->withBody('Test body')
            ->sendMessage($this->deviceTokens);

        // Or
        return PushNotification::fromArray(['title' => 'Test Title', 'body' => 'Test body'])->sendMessage($this->deviceTokens);
    }
}
```

Example usage in **Notification** class:

```
use Illuminate\Notifications\Notification;
use Dptsi\PushNotification\Messages\FirebaseMessage;

class SendBirthdayReminder extends Notification
{
    /**
     * Get the notification's delivery channels.
     */
    public function via($notifiable)
    {
        return ['firebase'];
    }

    /**
     * Get the firebase representation of the notification.
     */
    public function toFirebase($notifiable)
    {
        $deviceTokens = [
            '{TOKEN_1}',
            '{TOKEN_2}'
        ];

        return (new FirebaseMessage)
            ->withTitle('Hey, ', $notifiable->first_name)
            ->withBody('Happy Birthday!')
            ->asNotification($deviceTokens); // OR ->asMessage($deviceTokens);
    }
}
```

### Tips

[](#tips)

- Check example how to receive messages or push notifications in a [JavaScript client](/javascript-client).
- You can use `pushnotification()` helper instead of Facade.

### Payload

[](#payload)

Check how is formed payload to send to firebase:

Example 1:

```
PushNotification::withTitle('Test Title')->withBody('Test body')->sendNotification('token1');
```

```
{
  "registration_ids": [
    "token1"
  ],
  "notification": {
    "title": "Test Title",
    "body": "Test body"
  },
  "priority": "normal"
}
```

Example 2:

```
PushNotification::withTitle('Test Title')->withBody('Test body')->sendMessage('token1');
```

```
{
  "registration_ids": [
    "token1"
  ],
  "data": {
    "title": "Test Title",
    "body": "Test body"
  }
}
```

If you want to create payload from scratch you can use method `fromRaw`, for example:

```
return PushNotification::fromRaw([
    'registration_ids' => ['token1', 'token2'],
    'data' => [
        'key_1' => 'Value 1',
        'key_2' => 'Value 2'
    ],
    'android' => [
        'ttl' => '1000s',
        'priority' => 'normal',
        'notification' => [
            'key_1' => 'Value 1',
            'key_2' => 'Value 2'
        ],
    ],
])->send();
```

---

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/325c06ca594835aa37001ef03863e1d189286e9d55e61f3e34e2dfc951b6dd93?d=identicon)[dptsi](/maintainers/dptsi)

---

Top Contributors

[![bagusnusantara](https://avatars.githubusercontent.com/u/19530857?v=4)](https://github.com/bagusnusantara "bagusnusantara (7 commits)")

### Embed Badge

![Health badge](/badges/dptsi-laravel-push-notification/health.svg)

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

###  Alternatives

[tijsverkoyen/css-to-inline-styles

CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.

5.8k505.3M228](/packages/tijsverkoyen-css-to-inline-styles)[minishlink/web-push

Web Push library for PHP

1.9k12.0M53](/packages/minishlink-web-push)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[spatie/url-signer

Generate a url with an expiration date and signature to prevent unauthorized access

4422.3M16](/packages/spatie-url-signer)[mattketmo/email-checker

Throwaway email detection library

2742.0M5](/packages/mattketmo-email-checker)[laravel-notification-channels/discord

Laravel notification driver for Discord.

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

PHPackages © 2026

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