Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mustafahere/node-firebase-push-notification
An npm package that simplifies sending push notifications using Firebase Cloud Messaging (FCM) in Node.js applications.
https://github.com/mustafahere/node-firebase-push-notification
fcm firebase nodejs typescript
Last synced: about 1 month ago
JSON representation
An npm package that simplifies sending push notifications using Firebase Cloud Messaging (FCM) in Node.js applications.
- Host: GitHub
- URL: https://github.com/mustafahere/node-firebase-push-notification
- Owner: mustafahere
- License: mit
- Created: 2023-05-19T17:53:37.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-21T10:47:13.000Z (12 months ago)
- Last Synced: 2024-11-30T17:09:15.917Z (about 2 months ago)
- Topics: fcm, firebase, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 62.5 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Node Firebase Push Notification
[![npm version](https://img.shields.io/npm/v/node-firebase-push-notification.svg)](https://www.npmjs.com/package/node-firebase-push-notification)
[![License](https://img.shields.io/github/license/mustafahere/node-firebase-push-notification.svg)](https://github.com/mustafahere/node-firebase-push-notification/blob/main/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:
```bash
npm install node-firebase-push-notification
```## Usage
```js
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'` 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.