Sharing IOS Notification Template with Example ** Improved **

17DEC2020 Updated and improved flow credit to @dinomite and @lars_hassio

I’ve been using node red for about nine months now. I’ve taught myself a lot by reading the examples in the community. Now I am giving back.

I had been writing a ton of function nodes with different standards to set flow attributes and then create the payload to send to the notify service. I needed a standard that was easier to trouble shoot and create new notifications.

I created a template for creating IOS notifications for various state changes of my devices (EG. Garage Door, Person/Device Tracker, Low Temp, High Humidity etc.) using the change node to set attributes in the flow and then a function node to create the payload (see image:)

The change node is way easier to prevent errors often found when creating a function… almost like a config screen rather than script. (see image:) (note: use debug to find attributes)

A user can just change these to achieve the full alert. Much faster than in a function.

The function node create a full output including the target ios device captured in the change node.

[{"id":"b0037499.3da95","type":"tab","label":"Send IOS notification","disabled":false,"info":""},{"id":"25f6a3c4.a9529c","type":"api-call-service","z":"b0037499.3da95","name":"Notify IOS with Message","server":"67813a04.5b8c44","version":1,"debugenabled":false,"service_domain":"notify","service":"{{topic}}","entityId":"","data":"{}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":570,"y":80,"wires":[[]]},{"id":"bc58bd96.f3c118","type":"function","z":"b0037499.3da95","name":"Create IOS Alert","func":"var title = msg.title\nvar message1 = msg.message1\nvar message2 = msg.message2\nvar message3 = msg.message3\nvar sound = msg.sound\nvar critical = msg.critical\nvar volume = msg.volume\nvar target = msg.target\nvar final_msg = `${message1}` + `${message2}` + `${message3}`\nvar payload = {\"data\":\n{\n    \"message\": `${final_msg}`,\n    \"title\": `${title}`,\n    \"data\": {\n        \"push\": {\n          \"sound\": {\n            \"name\": `${sound}`,\n            \"critical\": `${critical}`,\n            \"volume\": `${volume}`,\n          }\n        }\n    }\n}\n}\nmsg.payload = payload\nmsg.topic = target\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":80,"wires":[["25f6a3c4.a9529c","c0fca00f.9cc418"]]},{"id":"b6171fec.b478f","type":"link in","z":"b0037499.3da95","name":"Notify IOS device","links":["d7251e74.62a8","4228d7d2.9665a","5e35c380.002684","ec0ac1b8.f6e2c","122218d1.a45127","6e18dd1c.d1749c","ab90d39c.05bdb","e1b05caa.b9c398"],"x":205,"y":80,"wires":[["bc58bd96.f3c118"]]},{"id":"c0fca00f.9cc418","type":"debug","z":"b0037499.3da95","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":530,"y":140,"wires":[]},{"id":"1698a445.48925c","type":"change","z":"b0037499.3da95","name":"Set notification attributes","rules":[{"t":"set","p":"title","pt":"msg","to":"string, payload or whatever input","tot":"str"},{"t":"set","p":"message1","pt":"msg","to":"string, payload or whatever input","tot":"str"},{"t":"set","p":"message2","pt":"msg","to":"string, payload or whatever input","tot":"msg"},{"t":"set","p":"message3","pt":"msg","to":"string, payload or whatever input","tot":"str"},{"t":"set","p":"critical","pt":"msg","to":"0 or 1","tot":"str"},{"t":"set","p":"sound","pt":"msg","to":"default (critical notifications has different default sound than non critical) or wav: https://companion.home-assistant.io/docs/notifications/notification-sounds/#pre-installed-notification-sounds","tot":"str"},{"t":"set","p":"volume","pt":"msg","to":"1.0 (100%) or 0.n (n %)","tot":"str"},{"t":"set","p":"target","pt":"msg","to":"mobile_app_<your_device_id_here>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":280,"wires":[["5e35c380.002684"]]},{"id":"5e35c380.002684","type":"link out","z":"b0037499.3da95","name":"","links":["b6171fec.b478f"],"x":475,"y":280,"wires":[]},{"id":"e261ebe9.72552","type":"debug","z":"b0037499.3da95","name":"Full debug to find attributes","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":340,"y":320,"wires":[]},{"id":"c4ed5703.3e243","type":"comment","z":"b0037499.3da95","name":"Template. Copy to flow to trigger notification","info":"","x":390,"y":220,"wires":[]},{"id":"774817b3.4b9e38","type":"inject","z":"b0037499.3da95","name":"Timestamp","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":480,"wires":[["7703e780.30409"]]},{"id":"307cb987.3a7da6","type":"change","z":"b0037499.3da95","name":"Set notification attributes","rules":[{"t":"set","p":"title","pt":"msg","to":"Time notification","tot":"str"},{"t":"set","p":"message1","pt":"msg","to":"The time is ","tot":"str"},{"t":"set","p":"message2","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"message3","pt":"msg","to":". I think you need more coffee!","tot":"str"},{"t":"set","p":"sound","pt":"msg","to":"default","tot":"str"},{"t":"set","p":"critical","pt":"msg","to":"0","tot":"str"},{"t":"set","p":"volume","pt":"msg","to":"0.5","tot":"str"},{"t":"set","p":"target","pt":"msg","to":"mobile_app_<your_device_id_here>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":480,"wires":[["e1b05caa.b9c398"]]},{"id":"e1b05caa.b9c398","type":"link out","z":"b0037499.3da95","name":"","links":["b6171fec.b478f"],"x":695,"y":480,"wires":[]},{"id":"7703e780.30409","type":"moment","z":"b0037499.3da95","name":"","topic":"","input":"payload","inputType":"msg","inTz":"Europe/Oslo","adjAmount":"1","adjType":"hours","adjDir":"add","format":"LLL","locale":"","output":"payload","outputType":"msg","outTz":"Europe/Oslo","x":320,"y":480,"wires":[["307cb987.3a7da6"]]},{"id":"e1226738.36c868","type":"comment","z":"b0037499.3da95","name":"Example. Insert you app id into \"set notification attributes\" node and trigger timestamp to send notification","info":"","x":420,"y":420,"wires":[]},{"id":"291fa529.9849ca","type":"comment","z":"b0037499.3da95","name":"Nodes to create messages and send notifications triggered from other flows","info":"","x":450,"y":20,"wires":[]},{"id":"6431169a.33c2d8","type":"comment","z":"b0037499.3da95","name":"Select correct HA server before using","info":"","x":690,"y":100,"wires":[]},{"id":"67813a04.5b8c44","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Hope this helps; also open to constructive feedback!.

Next onto same for Alexa notify!

PaulText

8 Likes

Thank you, this is great!! This will be very useful in reducing the number of nodes required to make notifications/announcements to Iphone/Alexa/Sonos from numerous triggers. :+1:t3:

Thank you Paul, much cleaner solution. I like it.

Thanks a lot for this very clean example ! :heart_eyes:

I put the send-notification part of this into its own tab with a Link in node and a Change & Link out nodes that you can copy to any other flow where you want to send a notification.

[{"id":"1fa1380f.6d1008","type":"tab","label":"Send IOS notification","disabled":false,"info":""},{"id":"20c65116.07e35e","type":"api-call-service","z":"1fa1380f.6d1008","name":"Notify IOS with Message","server":"bdb90e96.26e69","version":1,"debugenabled":false,"service_domain":"notify","service":"mobile_app_balbinus","entityId":"","data":"{}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":570,"y":60,"wires":[[]]},{"id":"6ab3dd76.2b03f4","type":"function","z":"1fa1380f.6d1008","name":"Create IOS Alert","func":"var name = msg.alert_name\nvar message1 = msg.message1\nvar message2 = msg.friendly_name\nvar message3 = msg.message3\nvar sound = msg.sound\nvar target = msg.target\n\nvar final_msg = `${message1}` + `${message2}` + `${message3}`\nvar payload = {\"data\":\n{\n    \"message\": `${final_msg}`,\n    \"title\": `${name}`,\n    \"data\": {\n        \"sound\": `${sound}`\n    }\n}\n}\nmsg.payload = payload\nmsg.topic = `${target}`\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":60,"wires":[["20c65116.07e35e"]]},{"id":"4cac5f46.6911a","type":"link in","z":"1fa1380f.6d1008","name":"Notify IOS device","links":["d7251e74.62a8","4228d7d2.9665a","fb8bd19b.c563d8"],"x":205,"y":60,"wires":[["6ab3dd76.2b03f4","fa2cf63c.d8c2c"]]},{"id":"fa2cf63c.d8c2c","type":"debug","z":"1fa1380f.6d1008","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":310,"y":100,"wires":[]},{"id":"e63b800.818248","type":"change","z":"1fa1380f.6d1008","name":"Set Message Attributes","rules":[{"t":"set","p":"alert_name","pt":"msg","to":"Garage","tot":"str"},{"t":"set","p":"message1","pt":"msg","to":"","tot":"str"},{"t":"set","p":"friendly_name","pt":"msg","to":"Scout's","tot":"str"},{"t":"set","p":"message3","pt":"msg","to":" has been closed","tot":"str"},{"t":"set","p":"sound","pt":"msg","to":"","tot":"str"},{"t":"set","p":"target","pt":"msg","to":"mobile_app_decius","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":220,"wires":[["fb8bd19b.c563d8"]]},{"id":"fb8bd19b.c563d8","type":"link out","z":"1fa1380f.6d1008","name":"","links":["4cac5f46.6911a"],"x":475,"y":220,"wires":[]},{"id":"bdb90e96.26e69","type":"server","z":"","name":"Home Assistant","addon":true}]

great idea; even cleaner.

Could you please share the logic within creating IOS alert? I am having struggle building one myself. Thanks a lot.

here you go - use this for high humidity alerts

[{"id":"beb512f2.e28d7","type":"tab","label":"IOS Alerts","disabled":false,"info":""},{"id":"ac1c5edb.26ada","type":"inject","z":"beb512f2.e28d7","name":"Check Humidity","repeat":"","crontab":"0 8-20 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":320,"wires":[[]]},{"id":"cabe9d1c.f73ad","type":"api-current-state","z":"beb512f2.e28d7","name":"Basment Humidity","server":"2a12269e.94634a","version":1,"outputs":2,"halt_if":"60","halt_if_type":"num","halt_if_compare":"gt","override_topic":false,"entity_id":"sensor.basement_humidity","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":630,"y":320,"wires":[["c36a03c2.69bbf"],[]]},{"id":"c36a03c2.69bbf","type":"change","z":"beb512f2.e28d7","name":"Set Message Attributes","rules":[{"t":"set","p":"alert_name","pt":"flow","to":"Humidity Alert","tot":"str"},{"t":"set","p":"message1","pt":"flow","to":"Alert ","tot":"str"},{"t":"set","p":"friendly_name","pt":"flow","to":"data.attributes.friendly_name","tot":"msg"},{"t":"set","p":"message2","pt":"flow","to":" is high!  It is ","tot":"str"},{"t":"set","p":"state1","pt":"flow","to":"payload","tot":"msg"},{"t":"set","p":"message3","pt":"flow","to":" percent","tot":"str"},{"t":"set","p":"sound","pt":"flow","to":"default","tot":"str"},{"t":"set","p":"target","pt":"flow","to":"mobile_app_paul_xs","tot":"str"},{"t":"set","p":"echos","pt":"flow","to":"group.annoucement_echos","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":320,"wires":[["976cc72b.683a48"]]},{"id":"f5b8bcdf.f883c","type":"api-call-service","z":"beb512f2.e28d7","name":"Notify Target IOS with Message","server":"2a12269e.94634a","version":1,"debugenabled":false,"service_domain":"notify","service":"{{topic}}","entityId":"","data":"{}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1470,"y":340,"wires":[[]]},{"id":"976cc72b.683a48","type":"function","z":"beb512f2.e28d7","name":"Create IOS Alert","func":"var name = flow.get('alert_name')\n\nvar message1 = flow.get('message1')\nvar message2 = flow.get('message2')\nvar message3 = flow.get('message3')\nvar sound = flow.get('sound')\nvar target = flow.get('target')\nvar state1 = flow.get('state1')\nvar friendly_name = flow.get('friendly_name')\n\nvar final_msg = `${message1}` + `${friendly_name}` + `${message2}` + `${state1}` + `${message3}`\nvar payload = {\"data\":\n{\n    \"message\": `${final_msg}`,\n    \"title\": `${name}`,\n    \"data\": {\n        \"sound\": `${sound}`\n    }\n}\n}\nmsg.payload = payload\nmsg.topic = `${target}`\nreturn msg","outputs":1,"noerr":0,"x":1180,"y":340,"wires":[["f5b8bcdf.f883c"]]},{"id":"2a12269e.94634a","type":"server","z":"","name":"Hingham Home","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
1 Like

I am happy to find this thread!

I’m trying to build a sub-flow for sending a notification to my devices.
Base on the proprieties of this sub-flow, a function will be building the payload to send the notification node. It’s something similar you have done in this tread.

For example, if “apns-collapse-id” is on, this code needs to be added to the payload.

            ,
            "apns_headers": {
                "apns-collapse-id": `${apnsCollapseId}`
            }

I’m trying to build the payload in part with if statement, but I’m having an issue with the “{” and “,”.
Any help will be welcome!

Thanks

var title = "title";
var message = "message";
var sound = "default";
var apnsCollapseId = title + "_a343543";

msg.payload = 
{
  "data": 
    {
    "title": `${title}`,
        "message": `${message}`,
        "data": {
            "push": {
                "sound": `${sound}`
            },
            "apns_headers": {
                "apns-collapse-id": `${apnsCollapseId}`
            }
        }
    }
}
return msg;

Nice!
Note that it is also possible to submit your own notifications to the HA Notifications center, like what you see when a new integration is detected.

Domain: notify Service: mobile_app_~myphone~ – send to phone
Domain: notify Service: persistent_notification – send to HA Notification
Domain: notify Service: notify – send to e.g. phone + HA

For example, I use Node Red to publish a notification to my phone when the gate is opened, as this needs direct attention. Then I have a regularly scheduled (cron) shell script running on the RPi that makes backups and upload them to the cloud (DropBox). On completion it will publish a MQTT message with the completion status and some detail, and this in turn is picked up by Node Red and forwarded as persistent notification to HA to allow me to keep track of possible errors.

Thanks for sharing. I made some changes to the “create IOS alert” node from @dinomite example, in order to be able to send critical notifications with sound volume, as per documentation: Critical notifications | Home Assistant Companion Docs (home-assistant.io)

var name = msg.title
var message1 = msg.message1
var message2 = msg.message2
var message3 = msg.message3
var sound = msg.sound
var critical = msg.critical
var volume = msg.volume
var target = msg.target
var final_msg = `${message1}` + `${message2}` + `${message3}`
var payload = {"data":
{
    "message": `${final_msg}`,
    "title": `${name}`,
    "data": {
        "push": {
          "sound": {
            "name": `${sound}`,
            "critical": `${critical}`,
            "volume": `${volume}`,
          }
        }
    }
}
}
msg.payload = payload
msg.topic = target
return msg

The corresponding msg.critical and msg.volume also needs to be added to the “set message attributes” node.

Great - Very useful. Do you think I should edit the 1st post with these updates? For new followers… I will note what is updated…?

1 Like

Sure. I made a somewhat more explanatory flow with some documentation in both the template node and with comment nodes, that might be useful.

[{"id":"b0037499.3da95","type":"tab","label":"Send IOS notification","disabled":false,"info":""},{"id":"25f6a3c4.a9529c","type":"api-call-service","z":"b0037499.3da95","name":"Notify IOS with Message","server":"67813a04.5b8c44","version":1,"debugenabled":false,"service_domain":"notify","service":"{{topic}}","entityId":"","data":"{}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":570,"y":80,"wires":[[]]},{"id":"bc58bd96.f3c118","type":"function","z":"b0037499.3da95","name":"Create IOS Alert","func":"var title = msg.title\nvar message1 = msg.message1\nvar message2 = msg.message2\nvar message3 = msg.message3\nvar sound = msg.sound\nvar critical = msg.critical\nvar volume = msg.volume\nvar target = msg.target\nvar final_msg = `${message1}` + `${message2}` + `${message3}`\nvar payload = {\"data\":\n{\n    \"message\": `${final_msg}`,\n    \"title\": `${title}`,\n    \"data\": {\n        \"push\": {\n          \"sound\": {\n            \"name\": `${sound}`,\n            \"critical\": `${critical}`,\n            \"volume\": `${volume}`,\n          }\n        }\n    }\n}\n}\nmsg.payload = payload\nmsg.topic = target\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":80,"wires":[["25f6a3c4.a9529c","c0fca00f.9cc418"]]},{"id":"b6171fec.b478f","type":"link in","z":"b0037499.3da95","name":"Notify IOS device","links":["d7251e74.62a8","4228d7d2.9665a","5e35c380.002684","ec0ac1b8.f6e2c","122218d1.a45127","6e18dd1c.d1749c","ab90d39c.05bdb","e1b05caa.b9c398"],"x":205,"y":80,"wires":[["bc58bd96.f3c118"]]},{"id":"c0fca00f.9cc418","type":"debug","z":"b0037499.3da95","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":530,"y":140,"wires":[]},{"id":"1698a445.48925c","type":"change","z":"b0037499.3da95","name":"Set notification attributes","rules":[{"t":"set","p":"title","pt":"msg","to":"string, payload or whatever input","tot":"str"},{"t":"set","p":"message1","pt":"msg","to":"string, payload or whatever input","tot":"str"},{"t":"set","p":"message2","pt":"msg","to":"string, payload or whatever input","tot":"msg"},{"t":"set","p":"message3","pt":"msg","to":"string, payload or whatever input","tot":"str"},{"t":"set","p":"critical","pt":"msg","to":"0 or 1","tot":"str"},{"t":"set","p":"sound","pt":"msg","to":"default (critical notifications has different default sound than non critical) or wav: https://companion.home-assistant.io/docs/notifications/notification-sounds/#pre-installed-notification-sounds","tot":"str"},{"t":"set","p":"volume","pt":"msg","to":"1.0 (100%) or 0.n (n %)","tot":"str"},{"t":"set","p":"target","pt":"msg","to":"mobile_app_<your_device_id_here>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":280,"wires":[["5e35c380.002684"]]},{"id":"5e35c380.002684","type":"link out","z":"b0037499.3da95","name":"","links":["b6171fec.b478f"],"x":475,"y":280,"wires":[]},{"id":"e261ebe9.72552","type":"debug","z":"b0037499.3da95","name":"Full debug to find attributes","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":340,"y":320,"wires":[]},{"id":"c4ed5703.3e243","type":"comment","z":"b0037499.3da95","name":"Template. Copy to flow to trigger notification","info":"","x":390,"y":220,"wires":[]},{"id":"774817b3.4b9e38","type":"inject","z":"b0037499.3da95","name":"Timestamp","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":480,"wires":[["7703e780.30409"]]},{"id":"307cb987.3a7da6","type":"change","z":"b0037499.3da95","name":"Set notification attributes","rules":[{"t":"set","p":"title","pt":"msg","to":"Time notification","tot":"str"},{"t":"set","p":"message1","pt":"msg","to":"The time is ","tot":"str"},{"t":"set","p":"message2","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"message3","pt":"msg","to":". I think you need more coffee!","tot":"str"},{"t":"set","p":"sound","pt":"msg","to":"default","tot":"str"},{"t":"set","p":"critical","pt":"msg","to":"0","tot":"str"},{"t":"set","p":"volume","pt":"msg","to":"0.5","tot":"str"},{"t":"set","p":"target","pt":"msg","to":"mobile_app_<your_device_id_here>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":480,"wires":[["e1b05caa.b9c398"]]},{"id":"e1b05caa.b9c398","type":"link out","z":"b0037499.3da95","name":"","links":["b6171fec.b478f"],"x":695,"y":480,"wires":[]},{"id":"7703e780.30409","type":"moment","z":"b0037499.3da95","name":"","topic":"","input":"payload","inputType":"msg","inTz":"Europe/Oslo","adjAmount":"1","adjType":"hours","adjDir":"add","format":"LLL","locale":"","output":"payload","outputType":"msg","outTz":"Europe/Oslo","x":320,"y":480,"wires":[["307cb987.3a7da6"]]},{"id":"e1226738.36c868","type":"comment","z":"b0037499.3da95","name":"Example. Insert you app id into \"set notification attributes\" node and trigger timestamp to send notification","info":"","x":420,"y":420,"wires":[]},{"id":"291fa529.9849ca","type":"comment","z":"b0037499.3da95","name":"Nodes to create messages and send notifications triggered from other flows","info":"","x":450,"y":20,"wires":[]},{"id":"6431169a.33c2d8","type":"comment","z":"b0037499.3da95","name":"Select correct HA server before using","info":"","x":690,"y":100,"wires":[]},{"id":"67813a04.5b8c44","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
2 Likes

Updated initial post with new flow.

I’ve also created actionable notifications but still working on templating. I’ll create a new post and link here and there when I do.

3 Likes

This is great and very helpful!

I have this working, but curious if you have an idea on how to take this one step further.

I am creating notifications for watching temps in my kids rooms so if it is <68 degrees my wife and I get a notification. I can set each up individually, but what I’d like is a function to capture whose room it is and then have a node compile it all. This would clean things up nicely and not have “notification attributes” node with hard coded room names.

Should work with Friendly Name if I am following. You’d have to use the Events All some how. I’ll play around with it this weekend

Thank you Works great

1 Like

Is there a version of this for android???

Good Day, Thank you for the great work, I use node-red as i cant seem to get my head around yaml, and i find the debugging much easier.
I would like to add the push category in the message as I want to use the actionable notifications, but im having issues with the json code.
Could you please include it in the nodered function node ?
This is from your code:

var title = msg.title
var message1 = msg.message1
var message2 = msg.message2
var message3 = msg.message3
var sound = msg.sound
var critical = msg.critical
var volume = msg.volume
var target = msg.target
var final_msg = ${message1} + ${message2} + ${message3}
var payload = {“data”:
{
“message”: ${final_msg},
“title”: ${title},
“data”: {
“push”: {
“sound”: {
“name”: ${sound},
“critical”: ${critical},
“volume”: ${volume},
}
}
}
}
}
msg.payload = payload
msg.topic = target
return msg

Below is the updated code. I believe this code is working. You will need to add the category as a variable in the attribute node as well. I included the node-red import code below as well. I haven’t worked through a good way to incorporate the ios.notification_action_fired into this flow, but its a start.

var title = msg.title
var message1 = msg.message1
var message2 = msg.message2
var message3 = msg.message3
var sound = msg.sound
var critical = msg.critical
var volume = msg.volume
var target = msg.target
var final_msg = `${message1}` + `${message2}` + `${message3}`
var category = msg.category
var payload = {"data":
{
    "message": `${final_msg}`,
    "title": `${title}`,
    "data": {
        "push": {
            "category": `${category}`,
          "sound": {
            "name": `${sound}`,
            "critical": `${critical}`,
            "volume": `${volume}`,
          }
        }
    }
}
}
msg.payload = payload
msg.topic = target
return msg
[{"id":"86323321.35c628","type":"tab","label":"Send IOS notification","disabled":false,"info":"https://community.home-assistant.io/t/sharing-ios-notification-template-with-example-improved/176838"},{"id":"ed90b55c.dfef4","type":"api-call-service","z":"86323321.35c628","name":"Notify IOS with Message","server":"2e80fdd.c0d6382","version":1,"debugenabled":false,"service_domain":"notify","service":"{{topic}}","entityId":"","data":"{}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":590,"y":180,"wires":[[]]},{"id":"42173f71.4d418","type":"function","z":"86323321.35c628","name":"Create IOS Alert","func":"var title = msg.title\nvar message1 = msg.message1\nvar message2 = msg.message2\nvar message3 = msg.message3\nvar sound = msg.sound\nvar critical = msg.critical\nvar volume = msg.volume\nvar target = msg.target\nvar final_msg = `${message1}` + `${message2}` + `${message3}`\nvar category = msg.category\nvar payload = {\"data\":\n{\n    \"message\": `${final_msg}`,\n    \"title\": `${title}`,\n    \"data\": {\n        \"push\": {\n            \"category\": `${category}`,\n          \"sound\": {\n            \"name\": `${sound}`,\n            \"critical\": `${critical}`,\n            \"volume\": `${volume}`,\n          }\n        }\n    }\n}\n}\nmsg.payload = payload\nmsg.topic = target\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":180,"wires":[["ed90b55c.dfef4","d75f80f6.6872b"]]},{"id":"70fd4ac3.94392c","type":"link in","z":"86323321.35c628","name":"Notify IOS device","links":["8208f178.0080d8","977743c0.ce5ab8","e2d84d6b.e86638","97dd65e6.d5de98"],"x":225,"y":180,"wires":[["42173f71.4d418"]]},{"id":"d75f80f6.6872b","type":"debug","z":"86323321.35c628","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":550,"y":240,"wires":[]},{"id":"13a7477.b0fe439","type":"change","z":"86323321.35c628","name":"Set notification attributes","rules":[{"t":"set","p":"title","pt":"msg","to":"string, payload or whatever input","tot":"str"},{"t":"set","p":"message1","pt":"msg","to":"string, payload or whatever input","tot":"str"},{"t":"set","p":"message2","pt":"msg","to":"string, payload or whatever input","tot":"msg"},{"t":"set","p":"message3","pt":"msg","to":"string, payload or whatever input","tot":"str"},{"t":"set","p":"critical","pt":"msg","to":"0 or 1","tot":"str"},{"t":"set","p":"sound","pt":"msg","to":"default (critical notifications has different default sound than non critical) or wav: https://companion.home-assistant.io/docs/notifications/notification-sounds/#pre-installed-notification-sounds","tot":"str"},{"t":"set","p":"volume","pt":"msg","to":"1.0 (100%) or 0.n (n %)","tot":"str"},{"t":"set","p":"target","pt":"msg","to":"mobile_app_<your_device_id_here>","tot":"str"},{"t":"set","p":"category","pt":"msg","to":"set_iOS_action_category_from_yaml","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":380,"wires":[["977743c0.ce5ab8"]]},{"id":"977743c0.ce5ab8","type":"link out","z":"86323321.35c628","name":"","links":["70fd4ac3.94392c"],"x":495,"y":380,"wires":[]},{"id":"4903bed8.fa4088","type":"debug","z":"86323321.35c628","name":"Full debug to find attributes","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":360,"y":420,"wires":[]},{"id":"4f858a81.64bb7c","type":"comment","z":"86323321.35c628","name":"Template. Copy to flow to trigger notification","info":"","x":410,"y":320,"wires":[]},{"id":"6c9b00d9.67813","type":"inject","z":"86323321.35c628","name":"Timestamp","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":580,"wires":[["eb39108e.465ab"]]},{"id":"5c235595.c7fb3c","type":"change","z":"86323321.35c628","name":"Set notification attributes","rules":[{"t":"set","p":"title","pt":"msg","to":"Time notification","tot":"str"},{"t":"set","p":"message1","pt":"msg","to":"The time is ","tot":"str"},{"t":"set","p":"message2","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"message3","pt":"msg","to":". I think you need more coffee!","tot":"str"},{"t":"set","p":"sound","pt":"msg","to":"default","tot":"str"},{"t":"set","p":"critical","pt":"msg","to":"1","tot":"str"},{"t":"set","p":"volume","pt":"msg","to":"0.5","tot":"str"},{"t":"set","p":"target","pt":"msg","to":"mobile_app_<your_device_id_here>","tot":"str"},{"t":"set","p":"category","pt":"msg","to":"set_iOS_action_category_from_yaml","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":580,"wires":[["8208f178.0080d8"]]},{"id":"8208f178.0080d8","type":"link out","z":"86323321.35c628","name":"","links":["70fd4ac3.94392c"],"x":715,"y":580,"wires":[]},{"id":"433b9ec4.d60c68","type":"comment","z":"86323321.35c628","name":"Example. Insert you app id into \"set notification attributes\" node and trigger timestamp to send notification","info":"","x":440,"y":520,"wires":[]},{"id":"1510041a.16cb2c","type":"comment","z":"86323321.35c628","name":"Nodes to create messages and send notifications triggered from other flows","info":"","x":470,"y":120,"wires":[]},{"id":"eb39108e.465ab","type":"moment","z":"86323321.35c628","name":"","topic":"","input":"payload","inputType":"msg","inTz":"America/Los_Angeles","adjAmount":"0","adjType":"hours","adjDir":"add","format":"LLL","locale":"en-US","output":"payload","outputType":"msg","outTz":"America/Los_Angeles","x":340,"y":580,"wires":[["5c235595.c7fb3c"]]},{"id":"26dba367.0a1524","type":"comment","z":"86323321.35c628","name":"Forum Thread","info":"https://community.home-assistant.io/t/sharing-ios-notification-template-with-example-improved/176838","x":270,"y":60,"wires":[]},{"id":"2e80fdd.c0d6382","type":"server","name":"Catt Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]