Hi all,
I've finally found time to implement the service I had been dreaming about for a long time.
Please welcome - FireNotify - Android application with free unlimited advanced notifications
It has API based on the free Google FCM service and allows you to send notifications to your Android phone which could be:
- ordinary (text, optional subject)
- silent
- grouped (several messages from the same group could be collapsed)
- persistent (cannot be dismissed by user)
- replaceable (new notification replaces previous having the same id)
- having custom images
- actionable (notification with action button(s) generating Node-Red message when pressed)
and so on
To send notifications from Node-Red the node-red-contrib-fcm-push-node node could be used.
Currently, it requires to specify FCM server key in FCM_SERVER_KEY environment variable (e.g. using settings.js instruction like process.env.FCM_SERVER_KEY = "AAAAaO...";
)
Use the next key for FireNotify service:
FCM_SERVER_KEY=AAAAaOmKSfc:APA91bGabQ9tUXtf5iUOycizl7Wpw0E875EiyxC8E9C2MyfMuG2anvfErYjrwEr4xFsoIVoIalqG4IupliY9436j4HNaL8jgDPEag2S0nSuI3TeU9TTbaK2bj8CFUVBDS6KCZib6Zo0X
And below is JSON content of the message payload that could be used to send a simple message to your phone:
{
"data":
{
"text": "Hello"
},
"to" : "TOKEN_FROM_ANDROID_APPLICATION",
"priority" : "high"
}
("priority" : "high" is a kind of hack for FCM service to deliver notification message even to the sleeping phone)
All supported parameters are present at the GitHub page of the project
To send an actionable notification you will need:
-
Install node-red-contrib-fcm-receive-node node to receive FCM messages, add it, register connection for the same FCM server key and check token printed to the Node-Red console
-
Make the next changes to the JSON of the message payload:
{
"data":
{
"text": "Hello",
"to": "TOKEN_FROM_NODE_RED",
"actions": [
{"title": "Press me", "data": {"action": "pressed"}}
]
},
"to" : "TOKEN_FROM_ANDROID_APPLICATION",
"priority" : "high"
}
And notification with single "Press me" action will appear on the screen. When action is pressed - "FCM receive" node will send message with content of "data" property of the action (payload.data.action = "pressed")
Enjoy!
P.S. I know that there could be some issues (for instance token in the Android application appears only on the second start) so your feedback is highly appreciated!
First example to import:
[{"id":"a9ca6f39.541e3","type":"inject","z":"9665c43f.7e5e38","name":"","topic":"","payload":"{\"data\":{\"text\":\"Hello\"},\"to\":\"TOKEN_FROM_ANDROID_APPLICATION\",\"priority\":\"high\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":380,"y":40,"wires":[["1afd39b2.5788e6"]]},{"id":"1afd39b2.5788e6","type":"fcm-push","z":"9665c43f.7e5e38","name":"","x":640,"y":140,"wires":[]}]
Second example to import:
[{"id":"6d296b66.521c74","type":"inject","z":"9665c43f.7e5e38","name":"","topic":"","payload":"{\"data\":{\"text\":\"Hello\",\"to\":\"TOKEN_FROM_NODE_RED\",\"actions\":[{\"title\":\"Press me\",\"data\":{\"action\":\"pressed\"}}]},\"to\":\"TOKEN_FROM_ANDROID_APPLICATION\",\"priority\":\"high\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":380,"y":90,"wires":[["1afd39b2.5788e6"]]},{"id":"1afd39b2.5788e6","type":"fcm-push","z":"9665c43f.7e5e38","name":"","x":640,"y":140,"wires":[]}]