PHPackages                             besanek/laravel-firebase-notifications - 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. besanek/laravel-firebase-notifications

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

besanek/laravel-firebase-notifications
======================================

Thin layer for integrate Firebase Messaging as Laravel Notifications

v5.1.0(2mo ago)040.5k↓32.7%1BSD-3-ClausePHPPHP ^8.3CI failing

Since Jun 26Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/besanek/laravel-firebase-notifications)[ Packagist](https://packagist.org/packages/besanek/laravel-firebase-notifications)[ RSS](/packages/besanek-laravel-firebase-notifications/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (12)Versions (17)Used By (0)

Laravel Firebase Notifications
==============================

[](#laravel-firebase-notifications)

Thin layer for integrate Firebase Messaging as Laravel Notifications

Requirement
-----------

[](#requirement)

- PHP &gt;= 8.3
- Laravel &gt;= 11.x

Installing
----------

[](#installing)

```
$ composer require "besanek/laravel-firebase-notifications"
```

This is all, thanks to the Package Autodiscover.

Setup
-----

[](#setup)

Please follow configuration guide of [kreait/laravel-firebase](https://github.com/kreait/laravel-firebase#configuration)

Basic Usage
-----------

[](#basic-usage)

Add new method `routeNotificationForFirebase` to your notifiable entity, witch returns device id.

```
    /**
     * It could be one device
     */
    public function routeNotificationForFirebase()
    {
        return $this->device_id;
    }

    /**
     * Or you can return array for multicast
     */
    public function routeNotificationForFirebase()
    {
        return $this->devices()->get()->pluck('id');
    }
```

In Notification entity you should add *firebase* to `via()` method.

```
    public function via(): array
    {
        return ['firebase', /* 'email', 'database', 'etc...'*/];
    }
```

And you can construct `CloudMessage` into `toFirebase()` method.

```
    public function toFirebase(): Messaging\CloudMessage
        $notification = Messaging\Notification::create('I
