1.1.1 • Published 9 months ago

@kazion/fcm-node-http v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

fcm-node-http

A Node.js client for the FCM HTTP v1 API.

Build Status Coverage Status

Installation

npm

npm install @kazion/fcm-node-http

yarn

yarn add @kazion/fcm-node-http

Usage

Example usage of the library Demo

import { FCM } from "@kazion/fcm-node-http";

const path_to_private_key = "path/to/private_key.json";

const fcm = new FCM(path_to_private_key);

Send a message

const fcmToken = "ee8-TV2BT7ucVYjesxPXdD:APA91bFQvY5sZdn6n1PW3kr...";

const message = {
  notification: {
    body: "body",
    title: "title",
    image:
      "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/React-icon.svg/120px-React-icon.svg.png",
  },
};
await fcm.send(fcmToken, message);

Send a message to multiple tokens

const fcmToken1 = "ee8-TV2BT7ucVYjesxPXdD:APA91bFQvY5sZdn6n1PW3kr...";
const fcmToken2 = "ee8-TV2BT7ucVYjesxPXdD:APA91bFQvY5sZdn6n1PW3kr...";

const message = {
  notification: {
    body: "body",
    title: "title",
    image:
      "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/React-icon.svg/120px-React-icon.svg.png",
  },
};
await fcm.sendAll([fcmToken1, fcmToken2], message);

main();

Feel free to contribute to this project by submitting a pull request.

Acknowledgements

This project was inspired by fcm-node

License

This project is licensed under the terms of the MIT license.

Support

If you have any questions, please open an issue

Author & Maintainer

This project was created by Patrick Kabwe