1.0.1 • Published 6 months ago
firebase-fcm-package v1.0.1
firebase-fcm-package
This package provides an easy-to-use interface for integrating Firebase Cloud Messaging (FCM) into your Node.js application. By using this package, you can easily send push notifications to individual devices or topics using Firebase Cloud Messaging services.
INSTALL
npm install firebase-fcm-package
USAGE
const FirebaseFCM = require('firebase-fcm-package');
const serviceAccount = require('./path/to/serviceAccountKey.json');
const fcm = new FirebaseFCM(serviceAccount);
Send a message to a device:
const token = 'device_fcm_token';
const message = {
title: 'New Message',
body: 'You have a new message!',
data: { key: 'value' },
};
fcm.sendMessageToDevice(token, message)
.then(response => console.log('Message sent:', response))
.catch(error => console.log('Error:', error));