@kazion/fcm-node-http
v1.1.1
Published
A Node.js client for the [FCM HTTP v1 API](https://firebase.google.com/docs/cloud-messaging/http-server-ref).
Downloads
30
Maintainers
Readme
fcm-node-http
A Node.js client for the FCM HTTP v1 API.
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