A simple Node script to send notifications to an iOS or Android device using Firebase Cloud Messaging.
npm install -s
node notification.js
if the notification was sent, done! will be printed in the console, the error will be printed otherwise.
This is just an example and the following variables MUST be changed to your custom values in order for this to work:
-
client1
This is the firebase token retrived by the device.
Visit Android instructions and this and this for iOS instructions.
-
API_KEY
Can be found in the firebase console, click in the 3 vertical dots in your proyect and then under the tab cloud messaging
-
serviceAccount
This is the .json file you download form firebase
-
databaseURL
Can be found in the firebase console under database
For further information about Firebase Cloud Messaging and how to build more complex notifications, please visit https://firebase.google.com/docs/cloud-messaging/downstream