1.0.3 • Published 3 months ago

fcm-traverse v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

FCM-Node

A Node.js simple interface to Google's Firebase Cloud Messaging (FCM). Supports both Android and iOS, including topic messages, and parallel calls. Additionally, it also keeps the callback behavior for the new Firebase Messaging service.

Installation

Via npm:

$ npm install fcm-node

Usage

Classic Usage

  1. Generate Server Key:

    Generate a Server Key on your app's Firebase console.

  2. Initialize FCM:

    Create an instance of the FCM class by passing your generated server key.

  3. Create Message:

    Build a message object with the necessary parameters.

  4. Send Message:

    Call the send() function on the FCM instance with the message object.

    Classic usage example:

    const FCM = require('fcm-node');
    const serverKey = 'YOURSERVERKEYHERE'; // Put your server key here
    const fcm = new FCM(serverKey);
    
    const message = {
        to: 'registration_token',
        collapse_key: 'your_collapse_key',
        notification: {
            title: 'Title of your push notification',
            body: 'Body of your push notification'
        },
        data: {
            my_key: 'my value',
            my_another_key: 'my another value'
        }
    };
    
    fcm.send(message, function(err, response) {
        if (err) {
            console.log("Something has gone wrong!");
        } else {
            console.log("Successfully sent with response:", response);
        }
    });
1.0.2

3 months ago

1.0.1

3 months ago

1.0.3

3 months ago

1.0.0

4 months ago