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

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

akshyaraait/laravel-fcm-notification
====================================

Laravel FCM (Firebase Cloud Messaging) Notification Channel

01.0kPHP

Since Dec 28Pushed 2y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

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

[](#laravel-fcm-notification)

Laravel FCM (Firebase Cloud Messaging) Notification Channel

[![GitHub tag](https://camo.githubusercontent.com/dafbdb519988f8330e1ab0929f03b7bf736e2417480a374f478376a2ae67f8b4/68747470733a2f2f62616467656e2e6e65742f6769746875622f7461672f616b7368796172616169742f6c61726176656c2d66636d2d6e6f74696669636174696f6e)](https://github.com/akshyaraait/laravel-fcm-notification/releases)[![Packagist](https://camo.githubusercontent.com/16cd5fd406476f4233f59c1f33fb10f2816b1a9880352d5978c10927efb024c7/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f616b7368796172616169742f6c61726176656c2d66636d2d6e6f74696669636174696f6e)](https://packagist.org/packages/akshyaraait/laravel-fcm-notification)[![Downloads](https://camo.githubusercontent.com/dca1a980b74281c4c52adac333ff354e40f3f2cad29eaf172f07b4b6c0594ec7/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f64742f616b7368796172616169742f6c61726176656c2d66636d2d6e6f74696669636174696f6e)](https://packagist.org/packages/akshyaraait/laravel-fcm-notification)[![License](https://camo.githubusercontent.com/f5fb280441cb78340421d0ee63b56f89aaa856a8b310c9f07c221918b14af10e/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f6c6963656e73652f616b7368796172616169742f6c61726176656c2d66636d2d6e6f74696669636174696f6e)](https://packagist.org/packages/akshyaraait/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 akshyaraait/laravel-fcm-notification
```

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

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

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity20

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/8dc8c10ff7f7365a9060dc5397facfea5f9badefb56ad12bca77d193e28a1fd4?d=identicon)[Akshyaraa](/maintainers/Akshyaraa)

---

Top Contributors

[![akshyaraait](https://avatars.githubusercontent.com/u/155069657?v=4)](https://github.com/akshyaraait "akshyaraait (2 commits)")

### Embed Badge

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

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

###  Alternatives

[tijsverkoyen/css-to-inline-styles

CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.

5.8k505.3M227](/packages/tijsverkoyen-css-to-inline-styles)[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)

PHPackages © 2026

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