通知按钮
概述
通知按钮通过button键值进行控制,可设置三个按钮(button_1、button_2、button_3),见下文示例。每个按钮通过name、actionType和action三个键值进行控制,其中name为按钮在通知栏的显示名称。支持以下几种使用方式,其中0~5的定义与通知点击动作相同。
| actionType | 0~5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|
| action | 同通知点击动作 | 标记为已读 | 标记为删除 | HTTP 请求 | 朗读 | 回复消息 |
{
"data": {
"uuid": "CWYMVYWQHoPGXEkh9yP5Nd",
"ttl": 86400,
"priority": "high",
"data": {
...
"button": {
"button_1": {
"actionType": 2,
"name": "打开 QQ",
"action": "com.tencent.mobileqq"
},
"button_2": {
"actionType": 5,
"name": "复制验证码",
"action": ""
},
"button_3": {
"actionType": 6,
"name": "标记为已读",
"action": ""
}
},
...
}
}
}
标记为已读
- 当
actionType(int)为6时(action无需设置),点击按钮会将该条消息标记为已读。
示例
{
"data": {
"uuid": "CWYMVYWQHoPGXEkh9yP5Nd",
"ttl": 86400,
"priority": "high",
"data": {
...
"button": {
"button_1": {
"actionType": 6,
"name": "标记为已读"
}
},
...
}
}
}
标记为删除
- 当
actionType(int)为7时(action无需设置),点击按钮会将该条消息标记为删除,在回收站中可见 。
示例
{
"data": {
"uuid": "CWYMVYWQHoPGXEkh9yP5Nd",
"ttl": 86400,
"priority": "high",
"data": {
...
"button": {
"button_1": {
"actionType": 7,
"name": "标记为删除"
}
},
...
}
}
}
HTTP 请求
- 当
actionType(int)为8,action(obj)可设置为如下 JSON 数据格式,点击按钮将发送 HTTP 请求。 - 可使用变量
${time}(发送请求的时间,例如2025-07-21 16:49:13)、${timestamp}(发送请求的时间戳)。
示例
{
"data": {
"uuid": "CWYMVYWQHoPGXEkh9yP5Nd",
"ttl": 86400,
"priority": "high",
"data": {
...
"button": {
"button_1": {
"actionType":8,
"name": "发送请求",
"action":{
"url": "https://aaa.bbb.com",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer xyz123",
"User-Agent": "NotifyMe/1.0"
},
"contentType": "application/json",
"content": {
"test": "1234",
"time": "${time}",
"timestamp": "${timestamp}"
}
}
}
},
...
}
}
}
朗读
- 当
actionType(int)为9时,action(obj)可设置为如下 JSON 数据格式,点击按钮会自动朗读消息内容(即body),再次点击按钮即停止朗读。 - 不设置
action时,将使用系统默认 tts 设置。
JSON 数据说明
speed:朗读语速,部分引擎可能无法设置;pitch:朗读语调,部分引擎可能无法设置;engine:朗读引擎,朗读引擎的包名,可自行安装 tts 引擎。
示例
{
"data": {
"uuid": "CWYMVYWQHoPGXEkh9yP5Nd",
"ttl": 86400,
"priority": "high",
"data": {
...
"button": {
"button_1": {
"actionType":9,
"name": "朗读",
"action":{
"speed": 0.5,
"pitch": 0.5,
"engine": "com.k2fsa.sherpa.onnx.tts.engine"
}
}
},
...
}
}
}
回复消息
- 当
actionType(int)为10时,action(obj)可设置为同 HTTP 请求中的 JSON 数据格式,点击按钮会显示消息回复框,填入消息后点击发送按钮即发送action所填的 HTTP 请求。 - 可使用变量
${replyText}(回复的文本)、${time}(发送请求的时间,例如2025-07-21 16:49:13)、${timestamp}(发送请求的时间戳)。
示例
{
"data": {
"uuid": "CWYMVYWQHoPGXEkh9yP5Nd",
"ttl": 86400,
"priority": "high",
"data": {
...
"button": {
"button_1": {
"actionType":10,
"name": "回复",
"action":{
"url": "https://aaa.bbb.com",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer xyz123",
"User-Agent": "NotifyMe/1.0"
},
"contentType": "application/json",
"content": {
"test": "1234",
"time": "${time}",
"timestamp": "${timestamp}",
"replyContent": "${replyText}"
}
}
}
},
...
}
}
}