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.

00PHP

Since Jul 30Pushed 9mo 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 1mo ago

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.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzM5NjkxNTEsIm5iZiI6MTc3Mzk2ODg1MSwicGF0aCI6Ii81ODk4MjQ2OS80NzI2Nzc4NzItZmVkYzBjNzEtYTVkZi00ZjRjLWJjOTQtNTQzNjQyOGRkMTkwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC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lpzzkss0aWvY3etiWC5kXBkMQWsoIQjC50ouHDFaA)
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.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzM5NjkxNTEsIm5iZiI6MTc3Mzk2ODg1MSwicGF0aCI6Ii81ODk4MjQ2OS80NzI2Nzg4MjItMjA5MTliMmYtZmYxMS00NmM3LWEzYzItODlhYjVjMjJmZTU2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAzMjAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMzIwVDAxMDczMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNjZWU2YjFkN2Y0MDFmMGQ3MGZhMGFkNWM5Y2UwYjBiNzc5NDg1MmI2YjE3MDM0NzVhY2VkMzkyMmZiYjhjYWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Ij3ctYKRPAY5fgKRDADLW8EfC6VjnGyvPSP4DqR5iA0)](https://private-user-images.githubusercontent.com/58982469/472678822-20919b2f-ff11-46c7-a3c2-89ab5c22fe56.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzM5NjkxNTEsIm5iZiI6MTc3Mzk2ODg1MSwicGF0aCI6Ii81ODk4MjQ2OS80NzI2Nzg4MjItMjA5MTliMmYtZmYxMS00NmM3LWEzYzItODlhYjVjMjJmZTU2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAzMjAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMzIwVDAxMDczMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNjZWU2YjFkN2Y0MDFmMGQ3MGZhMGFkNWM5Y2UwYjBiNzc5NDg1MmI2YjE3MDM0NzVhY2VkMzkyMmZiYjhjYWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Ij3ctYKRPAY5fgKRDADLW8EfC6VjnGyvPSP4DqR5iA0)
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

Maintenance40

Moderate activity, may be stable

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

[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)[eduardokum/laravel-mail-auto-embed

Library for embed images in emails automatically

1702.0M5](/packages/eduardokum-laravel-mail-auto-embed)

PHPackages © 2026

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