/node-send-fcm

Sample send FCM messages through node js using googleapis (latest FCM v1 API)

Primary LanguageJavaScriptMIT LicenseMIT

Send FCM messages with Node

A sample node project to send FCM notification using googleapis.

Requirements

  1. An existing firebase project, for the example we will use my-project
  2. A service account that can manage the firebase project. You can achieve that this way:
    1. Go to https://console.cloud.google.com/iam-admin/serviceaccounts?authuser=0 and login with the google account owner of the firebase project
    2. Select your firebase project and then you should see a single row in the grid with name firebase-adminsdk
    3. Click on the actions button of that row and click on Manage keys
    4. Click on Add key -> Create new key -> Key type: JSON -> Create
    5. This should automatically download your JWT key (json file).
    6. Place that file inside the ./auth/ folder of this project.
  3. Edit row 3 of the ./index.js file with the correct jwt key file name/path
  4. Edit row 6 of the ./index.js file with your project name

Send FCM messages

  1. Edit rows 7 and 8 with as you wish. You can follow the official FCM documentation
  2. Run
    npm install
    node index.js