Skip to content

Simplify push notifications with Firebase Cloud Messaging (FCM) API written with JavaScript.

Notifications You must be signed in to change notification settings

Mohammadtafakori01/FireBridge

Repository files navigation

FireBridge

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.

Installation

To use FireBridge in your project, follow these steps:

  1. Clone the repository or download the source code.
  2. Place your Firebase Admin SDK JSON file in the root directory of the project.
  3. Install dependencies by running npm install or yarn install.

Usage

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);
});

API

POST /api/sendFcmMessage

Send an FCM message with the provided title, body, and an optional link.

Request Body

  • title (string): Title of the notification.
  • body (string): Body content of the notification.
  • link (string, optional): Link URL to be included in the notification.

Response

  • Status Code: 200 OK
  • Body:
    {
      "message": "FCM message sent successfully!",
      "RetVal": true
    }

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Simplify push notifications with Firebase Cloud Messaging (FCM) API written with JavaScript.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published