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

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

bkief29/fcm
===========

FCM (Firebase Cloud Messaging) Notifications Driver for Laravel

2.2.1(5y ago)06MITPHPPHP &gt;=7.1.3

Since Jan 25Pushed 5y agoCompare

[ Source](https://github.com/bskiefer/fcm)[ Packagist](https://packagist.org/packages/bkief29/fcm)[ Docs](https://github.com/bskiefer/fcm)[ RSS](/packages/bkief29-fcm/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (15)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 5.5+, 6.x, 7.x and 8.x.

Version 2 Released (March 4, 2020)
----------------------------------

[](#version-2-released-march-4-2020)

V2.0.0 has been released and FCM API calls has been migrated from legacy HTTP to HTTP v1 (docs from Firebase [here](https://firebase.google.com/docs/cloud-messaging/migrate-v1)). This is a breaking change so notifications using v1.x should not upgrade to v2.x of this package unless you plan on migrating your notification classes.

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:~2.0
```

### 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

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

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

###  Release Activity

Cadence

Every ~30 days

Recently: every ~41 days

Total

14

Last Release

1902d ago

Major Versions

1.6.0 → 2.0.02020-03-04

1.7.0 → 2.0.12020-03-06

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

2.0.0PHP &gt;=7.1.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/3991afb5fcece92bbd6b0c772f708f6f1586e5077010f714ccaf01b052e8c857?d=identicon)[bskiefer](/maintainers/bskiefer)

---

Top Contributors

[![chrisbjr](https://avatars.githubusercontent.com/u/571279?v=4)](https://github.com/chrisbjr "chrisbjr (47 commits)")[![ankurk91](https://avatars.githubusercontent.com/u/6111524?v=4)](https://github.com/ankurk91 "ankurk91 (3 commits)")[![atymic](https://avatars.githubusercontent.com/u/50683531?v=4)](https://github.com/atymic "atymic (3 commits)")[![MathieuMaas](https://avatars.githubusercontent.com/u/34303750?v=4)](https://github.com/MathieuMaas "MathieuMaas (2 commits)")[![awkwardusername](https://avatars.githubusercontent.com/u/2331465?v=4)](https://github.com/awkwardusername "awkwardusername (2 commits)")[![timleland](https://avatars.githubusercontent.com/u/1711910?v=4)](https://github.com/timleland "timleland (2 commits)")[![drjdr](https://avatars.githubusercontent.com/u/55947988?v=4)](https://github.com/drjdr "drjdr (1 commits)")[![dwightwatson](https://avatars.githubusercontent.com/u/1100408?v=4)](https://github.com/dwightwatson "dwightwatson (1 commits)")[![edilbertloquine](https://avatars.githubusercontent.com/u/30011486?v=4)](https://github.com/edilbertloquine "edilbertloquine (1 commits)")[![ahmedsayedabdelsalam](https://avatars.githubusercontent.com/u/29691074?v=4)](https://github.com/ahmedsayedabdelsalam "ahmedsayedabdelsalam (1 commits)")[![gregorip02](https://avatars.githubusercontent.com/u/62108989?v=4)](https://github.com/gregorip02 "gregorip02 (1 commits)")[![hklsk](https://avatars.githubusercontent.com/u/8273423?v=4)](https://github.com/hklsk "hklsk (1 commits)")[![immeyti](https://avatars.githubusercontent.com/u/24190257?v=4)](https://github.com/immeyti "immeyti (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)")[![ramytamer](https://avatars.githubusercontent.com/u/7445123?v=4)](https://github.com/ramytamer "ramytamer (1 commits)")[![reinink](https://avatars.githubusercontent.com/u/882133?v=4)](https://github.com/reinink "reinink (1 commits)")[![ryzr](https://avatars.githubusercontent.com/u/9389421?v=4)](https://github.com/ryzr "ryzr (1 commits)")[![SaundersB](https://avatars.githubusercontent.com/u/4874111?v=4)](https://github.com/SaundersB "SaundersB (1 commits)")[![sdwru](https://avatars.githubusercontent.com/u/40401953?v=4)](https://github.com/sdwru "sdwru (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[laravel-notification-channels/fcm

FCM (Firebase Cloud Messaging) Notifications Driver for Laravel

5917.0M16](/packages/laravel-notification-channels-fcm)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[laravel-notification-channels/microsoft-teams

A Laravel Notification Channel for Microsoft Teams

1603.0M7](/packages/laravel-notification-channels-microsoft-teams)[laravel-notification-channels/discord

Laravel notification driver for Discord.

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

Push notification SDK(AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

682104.9k7](/packages/guanguans-notify)[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)

PHPackages © 2026

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