跳转至

通知按钮

概述

通知按钮通过button键值进行控制,可设置三个按钮(button_1button_2button_3),见下文示例。每个按钮通过nameactionTypeaction三个键值进行控制,其中name为按钮在通知栏的显示名称。支持以下几种使用方式,其中0~5的定义与通知点击动作相同。

actionType 0~5 6 7 8 9
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)为8action(obj)可设置为如下 JSON 数据格式,点击按钮将发送 HTTP 请求。
  • content可使用变量${time}(发送请求的时间,例如2025-07-21 16:49:13)、${timestamp}(发送请求的时间戳)。
    {
        "url": "https://test.example.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}"
        }
    }
    

示例

{
    "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 设置。
{
    "speed": 0.5,
    "pitch": 0.5,
    "engine": "com.k2fsa.sherpa.onnx.tts.engine"
}

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"
                    }
                }
            },
            ...
        }
    }
}