/fcm-push-cli

Need to test a custom Firebase Cloud Messaging Push Notification payload? Here you go 🚀

Primary LanguageJavaScript

FCM Push Notifications Test Script

Prerequisits

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.

  1. NodeJS >= v21 (stable native nodejs env file parsing & fetch support)
  2. yarn install to install all dependencies
  3. copy the content of .env.template and create a .env file near the package.json
  4. Add your device FCM_TOKEN into the .env file. This is the specific device token i.e returned by firebase.messaging().getToken()
  5. Place your generated service-account-file.json into the config directory, create the directory on package.json (root) level if not there
  6. 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.

Arrival of the Example Payload

Authors