PHPackages                             gitspark/fcmhttpv1 - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. gitspark/fcmhttpv1

ActiveLibrary[HTTP &amp; Networking](/categories/http)

gitspark/fcmhttpv1
==================

FCM HTTP V1 packages

0147↓85.7%PHP

Since Aug 23Pushed 1y agoCompare

[ Source](https://github.com/ShalomiH/fcmhttpv1)[ Packagist](https://packagist.org/packages/gitspark/fcmhttpv1)[ RSS](/packages/gitspark-fcmhttpv1/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel FCM Http V1 API Package
===============================

[](#laravel-fcm-http-v1-api-package)

A [Laravel](https://laravel.com/) package that lets you use the new FCM Http V1 API and send push notifications with ease.

Summary
-------

[](#summary)

1. [Install](https://github.com/ShalomiH/fcmhttpv1#install)
    - [Firebase](https://github.com/ShalomiH/fcmhttpv1#firebase)
    - [Laravel](https://github.com/ShalomiH/fcmhttpv1#laravel)
    - [Laravel PWA](https://github.com/ShalomiH/fcmhttpv1#laravel-pwa)
2. [Usage](https://github.com/ShalomiH/fcmhttpv1#usage)
    - [Topics](https://github.com/ShalomiH/fcmhttpv1#firebase)
        - [Subscribe](https://github.com/ShalomiH/fcmhttpv1#subscribe)
        - [Unsubscribe](https://github.com/ShalomiH/fcmhttpv1#unsubscribe)
        - [List subscriptions](https://github.com/ShalomiH/fcmhttpv1#list-subscriptions)
    - [Notification](https://github.com/ShalomiH/fcmhttpv1#notification)
        - [Send to unique token](https://github.com/ShalomiH/fcmhttpv1#send-to-unique-token)
        - [Send to topic](https://github.com/ShalomiH/fcmhttpv1#send-to-topic)

Install
-------

[](#install)

If your firebase project is already setup, you can skip that part and go to the [Usage section](https://github.com/ShalomiH/fcmhttpv1#usage) section.

The installation will take two steps. First we will build and manage the firebase project through the Firebase Console. Then we will see how you can implement the Firebase FCM Http V1 in your awesome Laravel project.

### Firebase

[](#firebase)

1. Go to the [Firebase console](https://console.firebase.google.com/u/0/).
2. Create a project
    [![Capture d’écran 2022-06-30 143010](https://user-images.githubusercontent.com/92929363/177950500-c2ab7f98-1593-461e-82c5-7d2065474e74.png)](https://user-images.githubusercontent.com/92929363/177950500-c2ab7f98-1593-461e-82c5-7d2065474e74.png)
3. Add a name
    [![Capture d’écran 2022-07-08 102739](https://user-images.githubusercontent.com/92929363/177950903-4b0ade29-2ce4-423f-980c-299444549030.png)](https://user-images.githubusercontent.com/92929363/177950903-4b0ade29-2ce4-423f-980c-299444549030.png)
4. Choose if you want to enable Analytics and create the project.
5. Add a Web App
    [![Capture d’écran 2022-07-08 103535](https://user-images.githubusercontent.com/92929363/177952387-b80d53e3-53f4-45b4-9050-e849b58e4e24.png)](https://user-images.githubusercontent.com/92929363/177952387-b80d53e3-53f4-45b4-9050-e849b58e4e24.png)
6. Add an app nickname
    [![Capture d’écran 2022-07-08 103625](https://user-images.githubusercontent.com/92929363/177952640-df8a5b86-7ce6-483e-9baf-a97751343378.png)](https://user-images.githubusercontent.com/92929363/177952640-df8a5b86-7ce6-483e-9baf-a97751343378.png)
7. Go into the project settings of the app, switch to the Service accounts tab then click on Generate new private key. It will download a json file containing credentials for your app.
8. Go to project settings, cloud messaging tab and enable CloudMessaging API ( click on the 3 dots on the right, Manage API in Google Cloud Console, and enable the API)
    [![Capture d’écran 2022-07-08 142946](https://user-images.githubusercontent.com/92929363/177992435-e29223f7-6189-4052-baa1-c0455b2cc092.png)](https://user-images.githubusercontent.com/92929363/177992435-e29223f7-6189-4052-baa1-c0455b2cc092.png)
9. Refresh firebase console page, a server key will be displayed under the Cloud Messaging API. (in Cloud Messaging tab)

Firebase configuration is now completed.

### Laravel

[](#laravel)

1. Put the downloaded json at the root of the project. (JSON downloaded at step 7 of Firebase configuration)
    [![Capture d’écran 2022-07-08 144029](https://user-images.githubusercontent.com/92929363/177993938-910ddac2-0472-45f3-9c30-3568e0e0244b.png)](https://user-images.githubusercontent.com/92929363/177993938-910ddac2-0472-45f3-9c30-3568e0e0244b.png)
2. Go to Firebase Console -&gt; Project Settings -&gt; General and watch firebaseConfig.
    [![Capture d’écran 2022-07-08 144454](https://user-images.githubusercontent.com/92929363/177994579-978d7fbc-5d23-4302-a66e-9d86edb8eb76.png)](https://user-images.githubusercontent.com/92929363/177994579-978d7fbc-5d23-4302-a66e-9d86edb8eb76.png)
3. Assign values to the .env variables

```
FCM_API_KEY=""
FCM_AUTH_DOMAIN=""
FCM_PROJECT_ID=""
FCM_STORAGE_BUCKET=""
FCM_MESSAGIN_SENDER_ID=""
FCM_APP_ID=""
FCM_JSON=""
FCM_API_SERVER_KEY=
```

4. Package installation

```
composer require gitspark/fcmhttpv1

```

5. Register the provider in config/app.php

```
gitspark\FcmHttpV1\FcmProvider::class,
```

6. Publish config file

```
php artisan vendor:publish --tag=fcmhttpv1 --ansi --force

```

### Laravel PWA

[](#laravel-pwa)

1. Please follow this [tutorial](https://github.com/silviolleite/laravel-pwa) to configure Laravel PWA.
2. Create a file "firebase-messaging-sw.js" at public folder of your project.

```
// Give the service worker access to Firebase Messaging.
// Note that you can only use Firebase Messaging here. Other Firebase libraries
// are not available in the service worker.
importScripts('https://www.gstatic.com/firebasejs/8.10.0/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/8.10.0/firebase-messaging.js');

// Initialize the Firebase app in the service worker by passing in
// your app's Firebase config object.
// https://firebase.google.com/docs/web/setup#config-object
firebase.initializeApp({
  apiKey: 'api-key',
  authDomain: 'project-id.firebaseapp.com',
  databaseURL: 'https://project-id.firebaseio.com',
  projectId: 'project-id',
  storageBucket: 'project-id.appspot.com',
  messagingSenderId: 'sender-id',
  appId: 'app-id',
});

// Retrieve an instance of Firebase Messaging so that it can handle background
// messages.
const messaging = firebase.messaging();
```

Usage
-----

[](#usage)

### Topics

[](#topics)

Topics are used to make groups of device tokens. They will allow you to send notification directly to the topic where users are registered in.

#### Subscribe

[](#subscribe)

To subscribe tokens to a topic :

```
use gitspark\FcmHttpV1\FcmTopicHelper;

$tokens = ["first token", ... , "last token"];
FcmTopicHelper::subscribeToTopic($tokens, "myTopic");
```

#### Unsubscribe

[](#unsubscribe)

```
use gitspark\FcmHttpV1\FcmTopicHelper;

$tokens = ["first token", ... , "last token"];
FcmTopicHelper::unsubscribeToTopic($tokens, "myTopic");
```

#### List subscriptions

[](#list-subscriptions)

```
use gitspark\FcmHttpV1\FcmTopicHelper;

$token = "your awesome device token";
FcmTopicHelper::getTopicsByToken($token);
```

Notification
------------

[](#notification)

You can send notification to specific user or to topics.

### Send to unique token

[](#send-to-unique-token)

```
use gitspark\FcmHttpV1\FcmNotification;

$notif = new FcmNotification();
$notif->setTitle("Title")->setBody("Message here")->setIcon("icon.png")->setToken("put device token here")->setClickAction("/news")->send();
```

### Send to topic

[](#send-to-topic)

```
use gitspark\FcmHttpV1\FcmNotification;

$notif = new FcmNotification();
$notif->setTitle("Title")->setBody("Message here")->setIcon("icon.png")->setTopic("general_topic")->setClickAction("/news")->send();
```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 97.9% 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://avatars.githubusercontent.com/u/2805569?v=4)[gitspark](/maintainers/gitspark)[@gitspark](https://github.com/gitspark)

---

Top Contributors

[![agence-appy](https://avatars.githubusercontent.com/u/92929363?v=4)](https://github.com/agence-appy "agence-appy (46 commits)")[![ShalomiH](https://avatars.githubusercontent.com/u/90998772?v=4)](https://github.com/ShalomiH "ShalomiH (1 commits)")

### Embed Badge

![Health badge](/badges/gitspark-fcmhttpv1/health.svg)

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

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25126.1M82](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k24.3k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87965.9k114](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.4M91](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69127.2k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

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