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

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

tonini46/laravel-fcm-notification
=================================

Laravel FCM (Firebase Cloud Messaging) Notification Channel

1.0.1(1y ago)018MITPHPPHP ^7.1.3|^8.0

Since Aug 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/tonini46/laravel-fcm-notification)[ Packagist](https://packagist.org/packages/tonini46/laravel-fcm-notification)[ RSS](/packages/tonini46-laravel-fcm-notification/feed)WikiDiscussions main Synced yesterday

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

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

[](#laravel-fcm-notification)

Laravel FCM (Firebase Cloud Messaging) Notification Channel

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 tonini46/laravel-fcm-notification
```

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

```
// config/app.php
'providers' => [
    ...
    tonini46\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 tonini46\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 tonini46\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 tonini46\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 tonini46\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

25

—

LowBetter than 35% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

676d ago

### Community

Maintainers

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

---

Top Contributors

[![tonini46](https://avatars.githubusercontent.com/u/7890110?v=4)](https://github.com/tonini46 "tonini46 (3 commits)")

---

Tags

laravelnotificationsfirebaseFCM

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[api-platform/laravel

API Platform support for Laravel

58171.5k14](/packages/api-platform-laravel)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M345](/packages/psalm-plugin-laravel)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M164](/packages/spatie-laravel-health)[propaganistas/laravel-disposable-email

Disposable email validator

6023.0M6](/packages/propaganistas-laravel-disposable-email)[benwilkins/laravel-fcm-notification

Laravel FCM (Firebase Cloud Messaging) Notification Channel

210970.8k1](/packages/benwilkins-laravel-fcm-notification)

PHPackages © 2026

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