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