RainMaker 推送通知 Payload
请按照 推送通知 中的步骤配置并启用推送通知。
推送通知方案
安卓系统
亚马逊 SNS 服务支持 Firebase Cloud Messaging (FCM) 向安卓用户发送通知。谷歌云端推送(Google Cloud Messaging, GCM)是其原版,现已弃用。亚马逊 SNS 服务在 FCM 和 GCM 后台使用的都是 FCM。
RainMaker 推送通知 payload 的格式为:
{
"GCM": "Escaped JSON event details with FCM supported attributes"
}
手机应用收到的 Escaped JSON 事件详情的格式为:
{
"data": {
"title": "ESP RainMaker",
"body": "",
"event_data_payload": {
"event_version": "v1",
"id": "1",
"event_type": "rmaker.event.<event_type>",
"timestamp": 1648563678737,
"description": "",
"event_data": {}
}
}
}
如果需要,您也可以更改通知的 payload。
iOS 系统
亚马逊 SNS 服务支持通过 苹果推送通知服务 (Apple Push Notification, APNs) 向 iOS 用户发送通知。您可以使用 APNs 沙盒通道向 APNs 的沙盒环境发送推送通知信息以进行产前测试。
RainMaker 推送通知 payload 的格式为:
{
"APNS/APNS_SANDBOX": "Escaped JSON event details with iOS supported attributes"
}
手机应用收到的 Escaped JSON 事件详情的格式为:
{
"aps": {
"alert": {
"title": "ESP RainMaker",
"body": "",
"event_data_payload": {
"event_version": "v1",
"id": "1",
"event_type": "rmaker.event.<event_type>",
"timestamp": 1648563678737,
"description": "",
"event_data": {}
}
},
"mutable-content": 1
}
}
如果需要,您也可以更改通知的 payload。点击 此处 参考更多信息。
推送通知 Payload
关于特定事件的推送通知 payload,请参考以下示例:
1. 已连接节点
安卓 | iOS |
---|---|
{ "GCM": "{\"data\":{\"title\":\"ESP RainMaker\",\"body\":\"Node(s) connected to cloud\",\"event_data_payload\":{\"event_version\":\"v1\",\"id\":\"1\",\"event_type\":\"rmaker.event.node_connected\",\"timestamp\":1648563678737,\"description\":\"Node(s) connected to cloud\",\"event_data\":{\"user_id\":\"1fd342a3-7531-48a0-9d97-4242a8502ed4\",\"node_id\":\"EPRoUZemZPDiHjKrHoD74f\",\"connectivity\":{\"connected\":true,\"timestamp\":1648563678517}}}}}" } | { "APNS": "{\"aps\":{\"alert\":{\"title\":\"ESP RainMaker\",\"body\":\"Node(s) connected to cloud\",\"event_data_payload\":{\"event_version\":\"v1\",\"id\":\"1\",\"event_type\":\"rmaker.event.node_connected\",\"timestamp\":1648563678737,\"description\":\"Node(s) connected to cloud\",\"event_data\":{\"user_id\":\"1fd342a3-7531-48a0-9d97-4242a8502ed4\",\"node_id\":\"EPRoUZemZPDiHjKrHoD74f\",\"connectivity\":{\"connected\":true,\"timestamp\":1648563678517}}}},\"mutable-content\":1}}" } |
2. 节点断开连接
安卓 | iOS |
---|---|
{ "GCM": "{\"data\":{\"title\":\"ESP RainMaker\",\"body\":\"Node(s) disconnected from cloud\",\"event_data_payload\":{\"event_version\":\"v1\",\"id\":\"1\",\"event_type\":\"rmaker.event.node_disconnected\",\"timestamp\":1648563564021,\"description\":\"Node(s) disconnected from cloud\",\"event_data\":{\"user_id\":\"1fd342a3-7531-48a0-9d97-4242a8502ed4\",\"node_id\":\"EPRoUZemZPDiHjKrHoD74f\",\"connectivity\":{\"connected\":false,\"timestamp\":1648563558181}}}}}" } | { "APNS": "{\"aps\":{\"alert\":{\"title\":\"ESP RainMaker\",\"body\":\"Node(s) disconnected from cloud\",\"event_data_payload\":{\"event_version\":\"v1\",\"id\":\"1\",\"event_type\":\"rmaker.event.node_disconnected\",\"timestamp\":1648563564021,\"description\":\"Node(s) disconnected from cloud\",\"event_data\":{\"user_id\":\"1fd342a3-7531-48a0-9d97-4242a8502ed4\",\"node_id\":\"EPRoUZemZPDiHjKrHoD74f\",\"connectivity\":{\"connected\":false,\"timestamp\":1648563558181}}}},\"mutable-content\":1}}" } |
3. 节点参数更改
安卓 | iOS |
---|---|
{ "GCM": "{\"data\":{\"title\":\"ESP RainMaker\",\"body\":\"Node parameters updated\",\"event_data_payload\":{\"event_version\":\"v1\",\"id\":\"1\",\"event_type\":\"rmaker.event.node_params_changed\",\"timestamp\":1648563339270,\"description\":\"Node parameters updated\",\"event_data\":{\"user_id\":\"1fd342a3-7531-48a0-9d97-4242a8502ed4\",\"node_id\":\"EPRoUZemZPDiHjKrHoD74f\",\"payload\":\"{\\\"Lightbulb\\\":{\\\"brightness\\\":75}}\"}}}}" } | { "APNS": "{\"aps\":{\"content-available\":1},\"data\":{\"title\":\"ESP RainMaker\",\"body\":\"Node parameters updated\",\"event_data_payload\":{\"event_version\":\"v1\",\"id\":\"1\",\"event_type\":\"rmaker.event.node_params_changed\",\"timestamp\":1648563339270,\"description\":\"Node parameters updated\",\"event_data\":{\"user_id\":\"1fd342a3-7531-48a0-9d97-4242a8502ed4\",\"node_id\":\"EPRoUZemZPDiHjKrHoD74f\",\"payload\":\"{\\\"Lightbulb\\\":{\\\"brightness\\\":75}}\"}}}}" } |
4. 添加用户节点
安卓 | iOS |
---|---|
{ "GCM": "{\"data\":{\"title\":\"ESP RainMaker\",\"body\":\"New Node(s) added\",\"event_data_payload\":{\"event_version\":\"v1\",\"id\":\"1\",\"event_type\":\"rmaker.event.user_node_added\",\"timestamp\":1648562696803,\"description\":\"New Node(s) added\",\"event_data\":{\"user_id\":\"69304cb1-7572-4981-87d8-eb06681ca699\",\"user_role\":\"primary\",\"nodes\":[\"WXXuKyL4HBTFbBQvxfCa6j\"]}}}}" } | { "APNS": "{\"aps\":{\"alert\":{\"title\":\"ESP RainMaker\",\"body\":\"New Node(s) added\",\"event_data_payload\":{\"event_version\":\"v1\",\"id\":\"1\",\"event_type\":\"rmaker.event.user_node_added\",\"timestamp\":1648562696803,\"description\":\"New Node(s) added\",\"event_data\":{\"user_id\":\"69304cb1-7572-4981-87d8-eb06681ca699\",\"user_role\":\"primary\",\"nodes\":[\"WXXuKyL4HBTFbBQvxfCa6j\"]}}},\"mutable-content\":1}}" } |
5. 删除用户节点
安卓 | iOS |
---|---|
{ "GCM": "{\"data\":{\"title\":\"ESP RainMaker\",\"body\":\"Node(s) removed\",\"event_data_payload\":{\"event_version\":\"v1\",\"id\":\"1\",\"event_type\":\"rmaker.event.user_node_removed\",\"timestamp\":1648563123598,\"description\":\"Node(s) removed by primary user\",\"event_data\":{\"user_id\":\"69304cb1-7572-4981-87d8-eb06681ca699\",\"user_role\":\"\",\"nodes\":[\"WXXuKyL4HBTFbBQvxfCa6j\"]}}}}" } | { "APNS": "{\"aps\":{\"alert\":{\"title\":\"ESP RainMaker\",\"body\":\"Node(s) removed\",\"event_data_payload\":{\"event_version\":\"v1\",\"id\":\"1\",\"event_type\":\"rmaker.event.user_node_removed\",\"timestamp\":1648563123598,\"description\":\"Node(s) removed by primary user\",\"event_data\":{\"user_id\":\"69304cb1-7572-4981-87d8-eb06681ca699\",\"user_role\":\"\",\"nodes\":[\"WXXuKyL4HBTFbBQvxfCa6j\"]}}},\"mutable-content\":1}}" } |
6. 节点警报
安卓 | iOS |
---|---|
{ "GCM": "{\"data\":{\"title\":\"ESP RainMaker\",\"body\":\"Alert received from a node\",\"event_data_payload\":{\"event_version\":\"v1\",\"id\":\"1\",\"event_type\":\"rmaker.event.alert\",\"timestamp\":1648706009358,\"description\":\"Alert received from a node\",\"event_data\":{\"message_body\":\"{\\\"Alert\\\":\\\"Sample alert\\\"}\",\"node_id\":\"EPRoUZemZPDiHjKrHoD74f\"}}}}" } | { "APNS": "{\"aps\":{\"alert\":{\"title\":\"ESP RainMaker\",\"body\":\"Alert received from a node\",\"event_data_payload\":{\"event_version\":\"v1\",\"id\":\"1\",\"event_type\":\"rmaker.event.alert\",\"timestamp\":1648706009358,\"description\":\"Alert received from a node\",\"event_data\":{\"message_body\":\"{\\\"Alert\\\":\\\"Sample alert\\\"}\",\"node_id\":\"EPRoUZemZPDiHjKrHoD74f\"}}},\"mutable-content\":1}}" } |
7. 触发节点自动化
安卓 | iOS |
---|---|
{ "GCM": "{\"data\":{\"title\":\"ESP RainMaker\",\"body\":\"Successfully triggered automation for some device(s)\",\"event_data_payload\":{\"event_version\":\"v1\",\"id\":\"1\",\"event_type\":\"rmaker.event.node_automation_trigger\",\"timestamp\":1648560446262,\"description\":\"Automation Triggered\",\"event_data\":{\"user_id\":\"1fd342a3-7531-48a0-9d97-4242a8502ed4\",\"automation_id\":\"a5rYFynf6XNjsNRJmarkbZ\",\"automation_name\":\"TurnOffWhen100\",\"node_id\":\"EPRoUZemZPDiHjKrHoD74f\",\"events\":[{\"params\":{\"Lightbulb\":{\"brightness\":100}},\"check\":\"==\"}],\"actions\":[{\"node_id\":\"EPRoUZemZPDiHjKrHoD74f\",\"params\":{\"Lightbulb\":{\"power\":false}}}],\"status\":[{\"node_id\":\"EPRoUZemZPDiHjKrHoD74f\",\"status\":\"success\",\"description\":\"Node automation triggered\"}]}}}}" } | { "APNS": "{\"aps\":{\"alert\":{\"title\":\"ESP RainMaker\",\"body\":\"Successfully triggered automation for some device(s)\",\"event_data_payload\":{\"event_version\":\"v1\",\"id\":\"1\",\"event_type\":\"rmaker.event.node_automation_trigger\",\"timestamp\":1648560446262,\"description\":\"Automation Triggered\",\"event_data\":{\"user_id\":\"1fd342a3-7531-48a0-9d97-4242a8502ed4\",\"automation_id\":\"a5rYFynf6XNjsNRJmarkbZ\",\"automation_name\":\"TurnOffWhen100\",\"node_id\":\"EPRoUZemZPDiHjKrHoD74f\",\"events\":[{\"params\":{\"Lightbulb\":{\"brightness\":100}},\"check\":\"==\"}],\"actions\":[{\"node_id\":\"EPRoUZemZPDiHjKrHoD74f\",\"params\":{\"Lightbulb\":{\"power\":false}}}],\"status\":[{\"node_id\":\"EPRoUZemZPDiHjKrHoD74f\",\"status\":\"success\",\"description\":\"Node automation triggered\"}]}}},\"mutable-content\":1}}" } |
8. 节点由用户共享
安卓 | iOS | ||
---|---|---|---|
用户 1 | 用户 2 | 用户 1 | 用户 2 |
场景:用户 1 向 用户 2 发送节点共享请求
|
|||
场景:用户 2 接受节点共享请求
|
|||
场景:用户 2 拒绝节点共享请求
|
|||
场景:用户 1 移除节点共享
|
|||
9. 节点组由用户共享
安卓 | iOS | ||
---|---|---|---|
用户 1 | 用户 2 | 用户 1 | 用户 2 |
场景:用户 1 向 用户 2 发送节点共享请求
|
|||
场景:用户 2 接受节点共享请求
|
|||
场景:用户 2 拒绝节点共享请求
|
|||
场景:用户 1 移除节点共享
|
|||
场景:用户 2 移除节点共享
|
|||