JSPM

  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q32798F
  • License ISC

A wrapper of firebase fcm rest api

Package Exports

  • firebase-fcm

Readme



Logo

Package for firebase push notification


Powered by Quokkalabs LLP

About The Package

It a wrapper package of firebase push notification REST api.
It can be used with ES5 and upper versions as well as with Typescript and Nest.js.


Built With

This package use following third party packages.

Axios Dotenv


Installation

Follow the steps to install and configure the package.

  1. Install NPM packages
npm install firebase-fcm
  1. Add environment variable in .env | .env.local | .env.development | .env.production
FIREBASE_SERVER_KEY="server-key"

OR

FirebaseFCM.config("server-key");

Usage

Import the package

If you use require for importing.

  const FirebaseFCM = require("firebase-fcm").default;

If you use import for importing.

  import FirebaseFCM from "firebase-fcm";

Send notification on single device.

  const response = await FirebaseFCM.sendOnMultiDevice(
    'token', 
    'title',
    'subject',
    'image-url',
    {}
  );
  console.log(response);

Send notification on multiple device.

  const response = await FirebaseFCM.sendOnSingleDevice(
    ['token1', 'token2'], 
    'title',
    'subject',
    'image-url',
    {}
  );
  console.log(response);