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

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

appstechnologies/laravel-fcm-notification
=========================================

Laravel FCM (Firebase Cloud Messaging) Notification Channel

03PHP

Since Aug 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Apps-Technologies/laravel-fcm-notification)[ Packagist](https://packagist.org/packages/appstechnologies/laravel-fcm-notification)[ RSS](/packages/appstechnologies-laravel-fcm-notification/feed)WikiDiscussions main 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/a6357ab8d236f3246930ec3ff7b7c774446beb4e93433acf382d3c1071d116f9/68747470733a2f2f62616467656e2e6e65742f6769746875622f7461672f417070732d546563686e6f6c6f676965732f6c61726176656c2d66636d2d6e6f74696669636174696f6e)](https://github.com/Apps-Technologies/laravel-fcm-notification/releases)[![Packagist](https://camo.githubusercontent.com/2a576eae57cdcdb384003de46aa0c51094333d09f2ce9eb6af34f25998a3bb1b/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f61707073746563686e6f6c6f676965732f6c61726176656c2d66636d2d6e6f74696669636174696f6e)](https://packagist.org/packages/appstechnologies/laravel-fcm-notification)[![Downloads](https://camo.githubusercontent.com/668dbe861dd572335a4f86cbf7ca575bd3f6cc2cdca52574b930638bd6624307/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f64742f61707073746563686e6f6c6f676965732f6c61726176656c2d66636d2d6e6f74696669636174696f6e)](https://packagist.org/packages/appstechnologies/laravel-fcm-notification)[![Build Status](https://camo.githubusercontent.com/e4af36a0daa6adbce49041b3650eade20809f9f579da389dd1fd6c03f0041a30/68747470733a2f2f7472617669732d63692e636f6d2f61707073746563686e6f6c6f676965732f6c61726176656c2d66636d2d6e6f74696669636174696f6e2e737667)](https://travis-ci.com/appstechnologies/laravel-fcm-notification)[![License](https://camo.githubusercontent.com/fcd521c0dfe9250b53cf66c4fcf81db59b51b93264e72f45d8fdac0c8a7307eb/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f6c6963656e73652f61707073746563686e6f6c6f676965732f6c61726176656c2d66636d2d6e6f74696669636174696f6e)](https://packagist.org/packages/appstechnologies/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 appstechnologies/laravel-fcm-notification
```

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

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

14

—

LowBetter than 2% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity17

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/d0ed0ee3d4d77f934d25164f05c92465d51573b71710efe041c3eafa2aa3643c?d=identicon)[appstechnologies](/maintainers/appstechnologies)

---

Top Contributors

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

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/appstechnologies-laravel-fcm-notification/health.svg)](https://phpackages.com/packages/appstechnologies-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)
