You need a service-account-file.json file which includes sensitive google acc credential information to retrieve an OAuth2 AccessToken and a Firebase Project-ID. You may read this Firebase Docs SDK Account Setup for further information about how to get that json!
Important: Extremely high security awareness is required when working with service account keys, as they are vulnerable to certain types of threats. See Best practices for managing service account keys.
- NodeJS >= v21 (stable native nodejs env file parsing & fetch support)
yarn install
to install all dependencies- copy the content of
.env.template
and create a.env
file near the package.json - Add your device
FCM_TOKEN
into the.env
file. This is the specific device token i.e returned by firebase.messaging().getToken() - Place your generated
service-account-file.json
into theconfig
directory, create the directory on package.json (root) level if not there - Run
yarn send
, on success your device recieves a push notification sent by firebase
If you want to know which properties inside a notification payload are supported by Firebase. See Firebase FCM message reference.
- Alessandro Lion - Initial work - Alessandro Lion