PHPackages                             jamespj/multidomain-fcm - 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. jamespj/multidomain-fcm

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

jamespj/multidomain-fcm
=======================

FCM (Firebase Cloud Messaging) Notifications Driver for Laravel

3.2.1(3y ago)013MITPHPPHP &gt;= 8.1

Since Jan 25Pushed 2y agoCompare

[ Source](https://github.com/JamesPJ/multidomain-fcm)[ Packagist](https://packagist.org/packages/jamespj/multidomain-fcm)[ Docs](https://github.com/laravel-notification-channels/fcm)[ RSS](/packages/jamespj-multidomain-fcm/feed)WikiDiscussions multidomain Synced today

READMEChangelogDependencies (6)Versions (31)Used By (0)

Laravel FCM (Firebase Cloud Messaging) Notification Channel
===========================================================

[](#laravel-fcm-firebase-cloud-messaging-notification-channel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/07629b7f221a0e4eabae0c966c2dd024fef3ab76c84746a72c3616fceadcb81a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f66636d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/coreproc/laravel-notification-channel-fcm)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![StyleCI](https://camo.githubusercontent.com/ad24ee26bcd92745afbd72c211a77cd3b18b9acbad6e3dd4389702ed5126f9db/68747470733a2f2f7374796c6563692e696f2f7265706f732f3230393430363732342f736869656c64)](https://styleci.io/repos/209406724)[![Quality Score](https://camo.githubusercontent.com/266e2de3b2df31065e9be378b85510184075047fbf804280c75d13fd07a8ae60/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f66636d2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/laravel-notification-channels/fcm)[![Total Downloads](https://camo.githubusercontent.com/0dd3851de895d9cde604bb40225dc04d4a2498e818723fd13b64631eea7b203d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f66636d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-notification-channels/fcm)

This package makes it easy to send notifications using [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/) (FCM) with Laravel.

Contents
--------

[](#contents)

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

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

[](#installation)

Install this package with Composer:

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

### Setting up the FCM service

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

This package now uses the [laravel-firebase](https://github.com/kreait/laravel-firebase) library to authenticate and make the API calls to Firebase. Follow the [configuration](https://github.com/kreait/laravel-firebase#configuration)steps specified in their readme before using this.

After following their configuration steps, make sure that you've specified your `FIREBASE_CREDENTIALS` in your .env file.

Usage
-----

[](#usage)

After setting up your Firebase credentials, you can now send notifications via FCM by a Notification class and sending it via the `FcmChannel::class`. Here is an example:

```
use Illuminate\Notifications\Notification;
use NotificationChannels\Fcm\FcmChannel;
use NotificationChannels\Fcm\FcmMessage;
use NotificationChannels\Fcm\Resources\AndroidConfig;
use NotificationChannels\Fcm\Resources\AndroidFcmOptions;
use NotificationChannels\Fcm\Resources\AndroidNotification;
use NotificationChannels\Fcm\Resources\ApnsConfig;
use NotificationChannels\Fcm\Resources\ApnsFcmOptions;

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

    public function toFcm($notifiable)
    {
        return FcmMessage::create()
            ->setData(['data1' => 'value', 'data2' => 'value2'])
            ->setNotification(\NotificationChannels\Fcm\Resources\Notification::create()
                ->setTitle('Account Activated')
                ->setBody('Your account has been activated.')
                ->setImage('http://example.com/url-to-image-here.png'))
            ->setAndroid(
                AndroidConfig::create()
                    ->setFcmOptions(AndroidFcmOptions::create()->setAnalyticsLabel('analytics'))
                    ->setNotification(AndroidNotification::create()->setColor('#0A0A0A'))
            )->setApns(
                ApnsConfig::create()
                    ->setFcmOptions(ApnsFcmOptions::create()->setAnalyticsLabel('analytics_ios')));
    }

    // optional method when using kreait/laravel-firebase:^3.0, this method can be omitted, defaults to the default project
    public function fcmProject($notifiable, $message)
    {
        // $message is what is returned by `toFcm`
        return 'app'; // name of the firebase project to use
    }
}
```

You will have to set a `routeNotificationForFcm()` method in your notifiable model. For example:

```
class User extends Authenticatable
{
    use Notifiable;

    ....

    /**
     * Specifies the user's FCM token
     *
     * @return string|array
     */
    public function routeNotificationForFcm()
    {
        return $this->fcm_token;
    }
}
```

You can also return an array of tokens to send notifications via multicast to different user devices.

```
class User extends Authenticatable
{
    use Notifiable;

    ....

    /**
     * Specifies the user's FCM tokens
     *
     * @return string|array
     */
    public function routeNotificationForFcm()
    {
        return $this->getDeviceTokens();
    }
}
```

Once you have that in place, you can simply send a notification to the user by doing the following:

```
$user->notify(new AccountActivated);
```

### Available Message methods

[](#available-message-methods)

The `FcmMessage` class contains the following methods for defining the payload. All these methods correspond to the available payload defined in the [FCM API documentation](https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages). Refer to this link to find all the available data you can set in your FCM notification.

```
setName(string $name)
```

```
setData(array $data)
```

```
setNotification(\NotificationChannels\Fcm\Resources\Notification $notification)
```

```
setAndroid(NotificationChannels\Fcm\Resources\AndroidConfig $androidConfig)
```

```
setApns(NotificationChannels\Fcm\Resources\ApnsConfig $apnsConfig)
```

```
setWebpush(NotificationChannels\Fcm\Resources\WebpushConfig $webpushConfig)
```

```
setFcmOptions(NotificationChannels\Fcm\Resources\FcmOptions $fcmOptions)
```

```
setTopic(string $topic)
```

```
setCondition(string $condition)
```

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)

- [Chris Bautista](https://github.com/chrisbjr)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Every ~47 days

Recently: every ~17 days

Total

28

Last Release

1062d ago

Major Versions

1.6.0 → 2.0.02020-03-04

1.7.0 → 2.0.12020-03-06

2.7.0 → 3.0.02023-02-07

PHP version history (3 changes)1.6.0PHP &gt;=7.0

2.0.0PHP &gt;=7.1.3

3.0.0PHP &gt;= 8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5469011?v=4)[JamesPJ](/maintainers/JamesPJ)[@JamesPJ](https://github.com/JamesPJ)

---

Top Contributors

[![chrisbjr](https://avatars.githubusercontent.com/u/571279?v=4)](https://github.com/chrisbjr "chrisbjr (47 commits)")[![dwightwatson](https://avatars.githubusercontent.com/u/1100408?v=4)](https://github.com/dwightwatson "dwightwatson (10 commits)")[![JamesPJ](https://avatars.githubusercontent.com/u/5469011?v=4)](https://github.com/JamesPJ "JamesPJ (5 commits)")[![atymic](https://avatars.githubusercontent.com/u/50683531?v=4)](https://github.com/atymic "atymic (5 commits)")[![marvelefe](https://avatars.githubusercontent.com/u/56586020?v=4)](https://github.com/marvelefe "marvelefe (4 commits)")[![ankurk91](https://avatars.githubusercontent.com/u/6111524?v=4)](https://github.com/ankurk91 "ankurk91 (3 commits)")[![timleland](https://avatars.githubusercontent.com/u/1711910?v=4)](https://github.com/timleland "timleland (2 commits)")[![awkwardusername](https://avatars.githubusercontent.com/u/2331465?v=4)](https://github.com/awkwardusername "awkwardusername (2 commits)")[![dododedodonl](https://avatars.githubusercontent.com/u/100052?v=4)](https://github.com/dododedodonl "dododedodonl (2 commits)")[![MathieuMaas](https://avatars.githubusercontent.com/u/34303750?v=4)](https://github.com/MathieuMaas "MathieuMaas (2 commits)")[![immeyti](https://avatars.githubusercontent.com/u/24190257?v=4)](https://github.com/immeyti "immeyti (1 commits)")[![edilbertloquine](https://avatars.githubusercontent.com/u/30011486?v=4)](https://github.com/edilbertloquine "edilbertloquine (1 commits)")[![jozefbalun](https://avatars.githubusercontent.com/u/8630488?v=4)](https://github.com/jozefbalun "jozefbalun (1 commits)")[![koenhoeijmakers](https://avatars.githubusercontent.com/u/2232776?v=4)](https://github.com/koenhoeijmakers "koenhoeijmakers (1 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")[![maisonsport-elukos](https://avatars.githubusercontent.com/u/80890147?v=4)](https://github.com/maisonsport-elukos "maisonsport-elukos (1 commits)")[![marcroberts](https://avatars.githubusercontent.com/u/43874?v=4)](https://github.com/marcroberts "marcroberts (1 commits)")[![drjdr](https://avatars.githubusercontent.com/u/55947988?v=4)](https://github.com/drjdr "drjdr (1 commits)")[![cmanish049](https://avatars.githubusercontent.com/u/4180846?v=4)](https://github.com/cmanish049 "cmanish049 (1 commits)")[![maximal](https://avatars.githubusercontent.com/u/980679?v=4)](https://github.com/maximal "maximal (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jamespj-multidomain-fcm/health.svg)

```
[![Health](https://phpackages.com/badges/jamespj-multidomain-fcm/health.svg)](https://phpackages.com/packages/jamespj-multidomain-fcm)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M164](/packages/spatie-laravel-health)[laravel-notification-channels/fcm

FCM (Firebase Cloud Messaging) Notifications Driver for Laravel

6008.0M23](/packages/laravel-notification-channels-fcm)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[laravel-notification-channels/expo

Expo Notifications Channel for Laravel

67628.6k1](/packages/laravel-notification-channels-expo)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)

PHPackages © 2026

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