Device token

Flows for Node-RED

To send push to app, you need to call a POST to 'https://fcm.googleapis.com/fcm/send' with a required json object.  Below flow has a function node to prepare JSON for POST node. Edit function node to modify title and body as you want



Note: Don't modify header object in function node!

[{"id":"8bb52021.c8f95","type":"function","z":"a7b82102.9b8d38","name":"","func":" msg.headers = {\n 'Authorization': 'key=AAAAZpLq_Bo:APA91bFMOTvQo1GyATp2_y5FEE1CNY4SJdWWGm_ZZpgVTBJGgcM-D0ZjBB5RWJm8hvfAkvL3b_-F8SoR_q8G66zuyiB0h11x4-PsuLHo1hTuCcbXKfC2AxrVUDw_l5JKIticSz23_jSP',\n 'Content-Type': 'application/json'\n }\n \n msg.payload = \n {\n \"to\" : \"YOUR DEVICE TOKEN\",\n \"notification\" : {\n \"body\" : \"Body of Your Notification\",\n \"title\": \"Title of Your Notification\"\n },\n \"data\": {\n \"notification_foreground\": \"true\"\n }\n}\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":160,"y":260,"wires":[["543f2f3b.6ba0a"]]},{"id":"543f2f3b.6ba0a","type":"http request","z":"a7b82102.9b8d38","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://fcm.googleapis.com/fcm/send","tls":"","persist":false,"proxy":"","authType":"","x":310,"y":340,"wires":[["d7a83959.bdf5b8"]]},{"id":"d7a83959.bdf5b8","type":"debug","z":"a7b82102.9b8d38","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":470,"y":320,"wires":[]}]