PHPackages                             algorithm-sam/laravel-fcm-notification - 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. algorithm-sam/laravel-fcm-notification

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

algorithm-sam/laravel-fcm-notification
======================================

Laravel FCM (Firebase Cloud Messaging) Notification Channel based off of AlgorithmSam/laravel-fcm-notification with support for laravel 10

v1.0.1(2y ago)08MITPHPPHP &gt;=5.6.4

Since May 6Pushed 2y agoCompare

[ Source](https://github.com/algorithm-sam/laravel-fcm-notification)[ Packagist](https://packagist.org/packages/algorithm-sam/laravel-fcm-notification)[ RSS](/packages/algorithm-sam-laravel-fcm-notification/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (7)Versions (3)Used By (0)

Laravel FCM Notification
========================

[](#laravel-fcm-notification)

Laravel FCM (Firebase Cloud Messaging) Notification Channel

[![GitHub tag](https://camo.githubusercontent.com/58fd0f0ea32a3cff20f6281a1543b0cba60a5f2af7605615a1bdab81d9dbd076/68747470733a2f2f62616467656e2e6e65742f6769746875622f7461672f62656e77696c6b696e732f6c61726176656c2d66636d2d6e6f74696669636174696f6e)](https://github.com/benwilkins/laravel-fcm-notification/releases)[![Packagist](https://camo.githubusercontent.com/8232b812f0fe58b4522e77b4943b0d5675ad83676d14fd11369325470993b14a/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f62656e77696c6b696e732f6c61726176656c2d66636d2d6e6f74696669636174696f6e)](https://packagist.org/packages/benwilkins/laravel-fcm-notification)[![Downloads](https://camo.githubusercontent.com/561b58ed965adbe72bb222660a6b03dad7e0467a702df7224050d0426356a892/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f64742f62656e77696c6b696e732f6c61726176656c2d66636d2d6e6f74696669636174696f6e)](https://packagist.org/packages/benwilkins/laravel-fcm-notification)[![Build Status](https://camo.githubusercontent.com/8580972fc85ed510c05b5e1e49ae64f0f7eed9620bbbd7b4c9acdfc64528d9d8/68747470733a2f2f7472617669732d63692e636f6d2f62656e77696c6b696e732f6c61726176656c2d66636d2d6e6f74696669636174696f6e2e737667)](https://travis-ci.com/benwilkins/laravel-fcm-notification)[![License](https://camo.githubusercontent.com/4e3c72b6c0aca78b0a7f45f436cabe06bef9fa954ec62650707553fed91806a9/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f6c6963656e73652f62656e77696c6b696e732f6c61726176656c2d66636d2d6e6f74696669636174696f6e)](https://packagist.org/packages/benwilkins/laravel-fcm-notification)

Use this package to send push notifications via Laravel to Firebase Cloud Messaging. Laravel 5.5+ required.

This package works only with [Legacy HTTP Server Protocol](https://firebase.google.com/docs/cloud-messaging/http-server-ref)

Install
-------

[](#install)

This package can be installed through Composer.

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

If installing on &lt; Laravel 5.5 then add the service provider:

```
// config/app.php
'providers' => [
    ...
    Benwilkins\FCM\FcmNotificationServiceProvider::class,
    ...
];
```

Add your Firebase API Key in `config/services.php`.

```
return [

    ...
    ...
    /*
     * Add the Firebase API key
     */
    'fcm' => [
        'key' => env('FCM_SECRET_KEY')
     ]
];
```

Example Usage
-------------

[](#example-usage)

Use Artisan to create a notification:

```
php artisan make:notification SomeNotification
```

Return `[fcm]` in the `public function via($notifiable)` method of your notification:

```
public function via($notifiable)
{
    return ['fcm'];
}
```

Add the method `public function toFcm($notifiable)` to your notification, and return an instance of `FcmMessage`:

```
use Benwilkins\FCM\FcmMessage;

...

public function toFcm($notifiable)
{
    $message = new FcmMessage();
    $message->content([
        'title'        => 'Foo',
        'body'         => 'Bar',
        'sound'        => '', // Optional
        'icon'         => '', // Optional
        'click_action' => '' // Optional
    ])->data([
        'param1' => 'baz' // Optional
    ])->priority(FcmMessage::PRIORITY_HIGH); // Optional - Default is 'normal'.

    return $message;
}
```

When sending to specific device, make sure your notifiable entity has `routeNotificationForFcm` method defined:

```
/**
 * Route notifications for the FCM channel.
 *
 * @param  \Illuminate\Notifications\Notification  $notification
 * @return string
 */
public function routeNotificationForFcm($notification)
{
    return $this->device_token;
}
```

When sending to a topic, you may define so within the `toFcm` method in the notification:

```
use Benwilkins\FCM\FcmMessage;

...

public function toFcm($notifiable)
{
    $message = new FcmMessage();
    $message->to('the-topic', $recipientIsTopic = true)
    ->content([...])
    ->data([...]);

    return $message;
}
```

Or when sending with a condition:

```
use Benwilkins\FCM\FcmMessage;

...

public function toFcm($notifiable)
{
    $message = new FcmMessage();
    $message->contentAvailable(true)
        ->priority('high')
        ->condition("'user_".$notifiable->id."' in topics")
        ->data([...]);

    return $message;
}
```

You may provide optional headers or override the request headers using `setHeaders()`:

```
use Benwilkins\FCM\FcmMessage;

...

public function toFcm($notifiable)
{
    $message = new FcmMessage();
    $message->setHeaders([
        'project_id'    =>  "48542497347"   // FCM sender_id
    ])->content([
        'title'        => 'Foo',
        'body'         => 'Bar',
        'sound'        => '', // Optional
        'icon'         => '', // Optional
        'click_action' => '' // Optional
    ])->data([
        'param1' => 'baz' // Optional
    ])->priority(FcmMessage::PRIORITY_HIGH); // Optional - Default is 'normal'.

    return $message;
}
```

Interpreting a Response
-----------------------

[](#interpreting-a-response)

To process any laravel notification channel response check [Laravel Notification Events](https://laravel.com/docs/6.0/notifications#notification-events)

This channel return a json array response:

```
 {
    "multicast_id": "number",
    "success": "number",
    "failure": "number",
    "canonical_ids": "number",
    "results": "array"
 }
```

Check [FCM Legacy HTTP Server Protocol](https://firebase.google.com/docs/cloud-messaging/http-server-ref#interpret-downstream)for response interpreting documentation.

License
-------

[](#license)

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

###  Health Score

22

—

LowBetter than 23% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 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 ~0 days

Total

2

Last Release

733d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7cef0c6f90d41df3fd8ec6fe4de25617452b42a7d27f23d8633678971ac0a100?d=identicon)[algorithm-sam](/maintainers/algorithm-sam)

---

Top Contributors

[![benwilkins](https://avatars.githubusercontent.com/u/1360229?v=4)](https://github.com/benwilkins "benwilkins (30 commits)")[![ramonvic](https://avatars.githubusercontent.com/u/87956?v=4)](https://github.com/ramonvic "ramonvic (19 commits)")[![chimit](https://avatars.githubusercontent.com/u/839349?v=4)](https://github.com/chimit "chimit (8 commits)")[![nicoqh](https://avatars.githubusercontent.com/u/3981388?v=4)](https://github.com/nicoqh "nicoqh (3 commits)")[![Skullbock](https://avatars.githubusercontent.com/u/1104083?v=4)](https://github.com/Skullbock "Skullbock (3 commits)")[![ankurk91](https://avatars.githubusercontent.com/u/6111524?v=4)](https://github.com/ankurk91 "ankurk91 (3 commits)")[![algorithm-sam](https://avatars.githubusercontent.com/u/28833334?v=4)](https://github.com/algorithm-sam "algorithm-sam (3 commits)")[![sonnysantino](https://avatars.githubusercontent.com/u/1275605?v=4)](https://github.com/sonnysantino "sonnysantino (1 commits)")[![wanghanlin](https://avatars.githubusercontent.com/u/2937647?v=4)](https://github.com/wanghanlin "wanghanlin (1 commits)")[![BahaaAlhagar](https://avatars.githubusercontent.com/u/25075512?v=4)](https://github.com/BahaaAlhagar "BahaaAlhagar (1 commits)")[![bobbybouwmann](https://avatars.githubusercontent.com/u/5872362?v=4)](https://github.com/bobbybouwmann "bobbybouwmann (1 commits)")[![Exidus1](https://avatars.githubusercontent.com/u/50305151?v=4)](https://github.com/Exidus1 "Exidus1 (1 commits)")[![Jono20201](https://avatars.githubusercontent.com/u/2374192?v=4)](https://github.com/Jono20201 "Jono20201 (1 commits)")[![morrislaptop](https://avatars.githubusercontent.com/u/67807?v=4)](https://github.com/morrislaptop "morrislaptop (1 commits)")[![patrickomeara](https://avatars.githubusercontent.com/u/571773?v=4)](https://github.com/patrickomeara "patrickomeara (1 commits)")

---

Tags

laravelnotificationsfirebaseFCM

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/algorithm-sam-laravel-fcm-notification/health.svg)

```
[![Health](https://phpackages.com/badges/algorithm-sam-laravel-fcm-notification/health.svg)](https://phpackages.com/packages/algorithm-sam-laravel-fcm-notification)
```

###  Alternatives

[benwilkins/laravel-fcm-notification

Laravel FCM (Firebase Cloud Messaging) Notification Channel

210964.1k1](/packages/benwilkins-laravel-fcm-notification)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[s-ichikawa/laravel-sendgrid-driver

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

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)

PHPackages © 2026

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