A Node.js client for the FCM HTTP v1 API.
npm
npm install @kazion/fcm-node-http
yarn
yarn add @kazion/fcm-node-http
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);
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);
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.
This project was inspired by fcm-node
This project is licensed under the terms of the MIT license.
If you have any questions, please open an issue
This project was created by Patrick Kabwe