FireBridge is a simple JavaScript library that facilitates sending push notifications using Firebase Cloud Messaging (FCM) API. It provides a straightforward API endpoint to send FCM messages with ease.
To use FireBridge in your project, follow these steps:
- Clone the repository or download the source code.
- Place your Firebase Admin SDK JSON file in the root directory of the project.
- Install dependencies by running
npm install
oryarn install
.
To send an FCM message, make a POST request to the /api/sendFcmMessage
endpoint with the following payload:
{
"title": "Notification Title",
"body": "Notification Body",
"link": "Optional Link URL"
}
Example:
const axios = require('axios');
axios.post('http://localhost:3000/api/sendFcmMessage', {
title: 'Hello World',
body: 'This is a test notification',
link: 'https://example.com'
})
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
});
Send an FCM message with the provided title, body, and an optional link.
title
(string): Title of the notification.body
(string): Body content of the notification.link
(string, optional): Link URL to be included in the notification.
- Status Code:
200 OK
- Body:
{ "message": "FCM message sent successfully!", "RetVal": true }
Contributions are welcome! Feel free to open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.