1.0.2 • Published 12 months ago

node-firebase-push-notification v1.0.2

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

Node Firebase Push Notification

npm version License

Node Firebase Push Notification is an npm package that simplifies sending push notifications using Firebase Cloud Messaging (FCM) in Node.js applications.

Installation

To install the package, use npm:

npm install node-firebase-push-notification

Usage

const { FirebaseAdmin } = require('node-firebase-push-notification');

// Initialize FirebaseAdmin with your credentials
FirebaseAdmin.initialize({
projectId: 'your-project-id',
privateKey: 'your-private-key',
clientEmail: 'your-client-email',
databaseURL: 'your-database-url'
});

// Get the FirebaseAdmin instance
const firebaseAdmin = FirebaseAdmin.getInstance();

// Send push notifications to a list of device tokens
firebaseAdmin.sendMulticastMessaging(
['deviceToken1', 'deviceToken2'],
'Notification Title',
'Notification Body',
{ customData: 'value' },
)
.then((batchResponse) => {
console.log('Push notification sent:', batchResponse);
})
.catch((error) => {
console.error('Error sending push notification:', error);
});

Please remember to replace the placeholders such as 'your-project-id', 'your-private-key', 'your-client-email', 'your-database-url', 'your-username', and 'link-to-your-documentation' with the appropriate values for your project.

Contributing

Contributions are welcome! Please follow the contribution guidelines before submitting a pull request.

License

This package is MIT licensed.

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago