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

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

riftweb/firebase-notifications
==============================

Effortlessly manage Firebase Cloud Messaging (FCM) notifications in your Laravel applications. This package simplifies sending FCM notifications with a clean and intuitive API, making it easy to integrate push notifications into your projects.

00PHPCI failing

Since Jul 30Pushed 11mo agoCompare

[ Source](https://github.com/riftwebdev/firebase-notifications)[ Packagist](https://packagist.org/packages/riftweb/firebase-notifications)[ RSS](/packages/riftweb-firebase-notifications/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Firebase Notifications 📩
========================

[](#firebase-notifications-)

[![Latest Version](https://camo.githubusercontent.com/ff7d6a6e3852166c0d21b16d0beb8660dc4b914413befcc21d850598c3685d2d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726966747765622f66697265626173652d6e6f74696669636174696f6e733f7374796c653d666c61742d737175617265)](https://packagist.org/packages/riftweb/firebase-notifications)[![Total Downloads](https://camo.githubusercontent.com/5ce0fb678d631dfd9877b37c0265620d129d2506ff847bfca3804e190eaf5091/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726966747765622f66697265626173652d6e6f74696669636174696f6e733f7374796c653d666c61742d737175617265)](https://packagist.org/packages/riftweb/firebase-notifications)[![License](https://camo.githubusercontent.com/eb917b712419d8305553aeb361d6aa028a99c8bb59c28921840d6494a31b1587/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f726966747765626465762f66697265626173652d6e6f74696669636174696f6e733f7374796c653d666c61742d737175617265)](https://github.com/riftwebdev/firebase-notifications/blob/main/LICENSE.md)[![Website](https://camo.githubusercontent.com/3d4462bc78796e728443098e8d62908e29f44e338bba51eb4b9a7bea1cf44cef/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f576562736974652d52494654253230253743253230576562253230446576656c6f706d656e742d626c61636b3f7374796c653d666c61742d737175617265)](https://riftweb.com)

A [Laravel](https://laravel.com/) package that lets you use the new FCM Http V1 API and send push notifications with ease.

Summary
-------

[](#summary)

1. [Install](https://github.com/riftwebdev/firebase-notifications#install)
    - [Laravel](https://github.com/riftwebdev/firebase-notifications#laravel)
2. [Usage](https://github.com/riftwebdev/firebase-notifications#usage)
    - [Topics](https://github.com/riftwebdev/firebase-notifications#firebase)
        - [Subscribe](https://github.com/riftwebdev/firebase-notifications#subscribe)
        - [Unsubscribe](https://github.com/riftwebdev/firebase-notifications#unsubscribe)
        - [List Token Subscribed Topics](https://github.com/riftwebdev/firebase-notifications#list-token--subscribed-topics)
    - [Notification](https://github.com/riftwebdev/firebase-notifications#notification)

Install
-------

[](#install)

If your Firebase project is already configured, skip this part and go to the [Usage section](https://github.com/riftwebdev/firebase-notifications#usage) section.

### Firebase

[](#firebase)

TBD

### Laravel

[](#laravel)

1. Install via Composer

```
composer require riftwebdev/firebase-notifications
```

2. Publish the config file

```
php artisan vendor:publish --tag=firebase-notifications --ansi --force
```

2. Place your Firebase JSON on your project.

    [![image](https://private-user-images.githubusercontent.com/58982469/472677872-fedc0c71-a5df-4f4c-bc94-5436428dd190.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODIyODk0MTksIm5iZiI6MTc4MjI4OTExOSwicGF0aCI6Ii81ODk4MjQ2OS80NzI2Nzc4NzItZmVkYzBjNzEtYTVkZi00ZjRjLWJjOTQtNTQzNjQyOGRkMTkwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUF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jAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRnBuZyJ9.BUnevRVdV8FHvX8KONIf4THHhLlM_u1IUcrVF8tcRkk)
3. Retrieve the .env variables from your Firebase Console -&gt; Project Settings -&gt; General and watch firebaseConfig.

    [![5](https://private-user-images.githubusercontent.com/58982469/472678822-20919b2f-ff11-46c7-a3c2-89ab5c22fe56.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODIyODk0MTksIm5iZiI6MTc4MjI4OTExOSwicGF0aCI6Ii81ODk4MjQ2OS80NzI2Nzg4MjItMjA5MTliMmYtZmYxMS00NmM3LWEzYzItODlhYjVjMjJmZTU2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA2MjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNjI0VDA4MTgzOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE4ODNlNzA0N2M3OTA0MzZiMDg4MDFkOTViMmMwMDA5MjMxY2U4MDE1YzU4MDJlYWQ5OWY1ZWFmYWY1NDI1YTUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRnBuZyJ9.6dfJoduJrybDtaKkJEqA_wKzFXJizJ1mKT2cJXIzJwQ)](https://private-user-images.githubusercontent.com/58982469/472678822-20919b2f-ff11-46c7-a3c2-89ab5c22fe56.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODIyODk0MTksIm5iZiI6MTc4MjI4OTExOSwicGF0aCI6Ii81ODk4MjQ2OS80NzI2Nzg4MjItMjA5MTliMmYtZmYxMS00NmM3LWEzYzItODlhYjVjMjJmZTU2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA2MjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNjI0VDA4MTgzOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE4ODNlNzA0N2M3OTA0MzZiMDg4MDFkOTViMmMwMDA5MjMxY2U4MDE1YzU4MDJlYWQ5OWY1ZWFmYWY1NDI1YTUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRnBuZyJ9.6dfJoduJrybDtaKkJEqA_wKzFXJizJ1mKT2cJXIzJwQ)
4. Assign values to the .env variables

```
FCM_API_KEY=""
FCM_AUTH_DOMAIN=""
FCM_PROJECT_ID=""
FCM_STORAGE_BUCKET=""
FCM_MESSAGING_SENDER_ID=""
FCM_APP_ID=""
FCM_JSON=""
```

Usage
-----

[](#usage)

### Topics

[](#topics)

Topics are used to make groups of device tokens. They will allow you to send notification directly to the topic where users are registered in.

#### Subscribe

[](#subscribe)

##### Single Token to Single Topic

[](#single-token-to-single-topic)

```
use Riftweb\FirebaseNotifications\Facades\FcmTokenTopic;

$token = "example token";
$topic = "exampleTopic";

FcmTokenTopic::subscribeToTopic($token, $topic);
```

##### Multiple Tokens to Single Topic

[](#multiple-tokens-to-single-topic)

```
use Riftweb\FirebaseNotifications\Facades\FcmTokenTopic;

$tokens = ["example token 1", "example token 2"];

$topic = "exampleTopic";

FcmTokenTopic::subscribeToTopic($tokens, $topic);
```

##### Single Token to Multiple Topics

[](#single-token-to-multiple-topics)

```
use Riftweb\FirebaseNotifications\Facades\FcmTokenTopic;

$token = "example token";
$topics = ["exampleTopic1", "exampleTopic2"];

FcmTokenTopic::subscribeToTopics($token, $topics);
```

##### Multiple Tokens to Multiple Topics

[](#multiple-tokens-to-multiple-topics)

```
use Riftweb\FirebaseNotifications\Facades\FcmTokenTopic;

$tokens = ["example token 1", "example token 2"];
$topics = ["exampleTopic1", "exampleTopic2"];

FcmTokenTopic::subscribeToTopics($tokens, $topics);
```

#### Unsubscribe

[](#unsubscribe)

##### Single Token to Single Topic

[](#single-token-to-single-topic-1)

```
use Riftweb\FirebaseNotifications\Facades\FcmTokenTopic;

$token = "example token";
$topic = "exampleTopic";

FcmTokenTopic::unsubscribeToTopic($token, $topic);
```

##### Multiple Tokens to Single Topic

[](#multiple-tokens-to-single-topic-1)

```
use Riftweb\FirebaseNotifications\Facades\FcmTokenTopic;

$tokens = ["example token 1", "example token 2"];

$topic = "exampleTopic";

FcmTokenTopic::unsubscribeToTopic($tokens, $topic);
```

##### Single Token to Multiple Topics

[](#single-token-to-multiple-topics-1)

```
use Riftweb\FirebaseNotifications\Facades\FcmTokenTopic;

$token = "example token";
$topics = ["exampleTopic1", "exampleTopic2"];

FcmTokenTopic::unsubscribeToTopics($token, $topics);
```

##### Multiple Tokens to Multiple Topics

[](#multiple-tokens-to-multiple-topics-1)

```
use Riftweb\FirebaseNotifications\Facades\FcmTokenTopic;

$tokens = ["example token 1", "example token 2"];
$topics = ["exampleTopic1", "exampleTopic2"];

FcmTokenTopic::unsubscribeToTopics($tokens, $topics);
```

#### List Token Subscribed Topics

[](#list-token-subscribed-topics)

```
use Riftweb\FirebaseNotifications\Facades\FcmTokenTopic;

$token = "example token 1";

FcmTokenTopic::getTopics($token);
```

Notification
------------

[](#notification)

You can send notification to specific tokens or to topics, and both at same time.

**Beware, if you set topics and tokens at same time, both will receive (whoever is subscribed to the topics + the extra tokens**

```
use Riftweb\FirebaseNotifications\Facades\FcmNotification;

FcmNotification::create()
  ->setTitle('Example Notification')
  ->setBody('Lorem ipsum dolores')
  ->setImage(asset('images/example.png'))
  ->setCategory('develop') // Compatible with iOS
  ->setSound('blingbling') // Compatible with iOS
  ->setFlutterClickAction() // Only use this if you're using flutter - Will set click_action as FLUTTER_NOTIFICATION_CLICK, otherwise use setClickAction()
  ->setLink('https://example.com') // Used for webpush notifications
  ->setData([
    'user_id' => 1,
    'foo' => 'bar'
  ]) // Extra Data
  ->setTopics(['topic 1', 'topic 2']) // Set this notification to be sent for certain topics
  ->setTokens(['token 1', 'token 2']) // Specify which tokens will receive this notification
  ->send();
```

### Notification Mapping

[](#notification-mapping)

```
 return [
            "notification" => [
                "title" => $this->title,
                "body" => $this->body,
                'image' => $image, // Used by Android/iOS
            ],
            "data" => $this->data,
            "android" => [
                "notification" => [
                    "click_action" => $this->click_action
                ]
            ],
            "apns" => [
                "payload" => [
                    "aps" => [
                        "category" => $this->category,
                        "sound" => $this->sound
                    ]
                ],
                "fcm_options" => [
                    "image" => $image,
                ]
            ],
            "webpush" => [
                "notification" => [
                    "title" => $this->title,
                    "body" => $this->body,
                    "icon" => $image,
                ],
                "fcm_options" => [
                    "link" => $this->link
                ]
            ]
        ];
```

Contributing 🤝
--------------

[](#contributing-)

Contributions are welcome! Please follow:

1. Fork the repository
2. Create your feature branch
3. Commit changes
4. Push to the branch
5. Open a PR

License 📄
---------

[](#license-)

MIT License - See [LICENSE](LICENSE.md) for details.

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

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/fe87ff5100151537627360a705cb255f2b0e9f6d2e71c04e40514832fa4bea14?d=identicon)[riftweb](/maintainers/riftweb)

---

Top Contributors

[![riftwebdev](https://avatars.githubusercontent.com/u/58982469?v=4)](https://github.com/riftwebdev "riftwebdev (2 commits)")

### Embed Badge

![Health badge](/badges/riftweb-firebase-notifications/health.svg)

```
[![Health](https://phpackages.com/badges/riftweb-firebase-notifications/health.svg)](https://phpackages.com/packages/riftweb-firebase-notifications)
```

###  Alternatives

[maize-tech/laravel-email-domain-rule

Laravel Email Domain Rule

612.0k](/packages/maize-tech-laravel-email-domain-rule)[sarfraznawaz2005/noty

Laravel package to incorporate noty flash notifications into laravel.

324.5k](/packages/sarfraznawaz2005-noty)

PHPackages © 2026

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