Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

小米推送

Feature: push-xiaomi

小米推送 V3 API,支持通知/透传/regid/别名/标签/广播。

配置

[push.xiaomi]
package_name = ""
app_secret = ""
# base_url = "https://api.xmpush.xiaomi.com"

API

send(target, notification, options) — 发送通知

#![allow(unused)]
fn main() {
let result = state.push.xiaomi.send(
    &PushTarget::Cid("registration_id".to_string()),
    &Notification::new("标题", "内容"),
    None,
).await?;
}

send_transmission(target, content, options) — 发送透传

#![allow(unused)]
fn main() {
let result = state.push.xiaomi.send_transmission(
    &PushTarget::Cid("registration_id".to_string()),
    "{\"action\":\"refresh\"}",
    None,
).await?;
}

推送目标

PushTarget接口说明
Cid/v3/message/regid单个 regid
CidList/v3/message/regid多个 regid(逗号分隔)
Alias/v3/message/alias单个别名
AliasList/v3/message/alias多个别名
Tag/v3/message/topic标签
All/v3/message/all广播

推送选项

选项说明
time_to_live消息有效期(毫秒)
time_to_send定时发送(毫秒时间戳)
notify_id通知栏 ID(覆盖)
notify_type1=声音, 2=震动, 3=声音+震动, 4=静默
channel_idAndroid 通知渠道
notify_effect1=打开首页, 2=打开Activity, 3=打开网页
web_uri打开网页(notify_effect=3)
intent_uri打开 Activity(notify_effect=2)
sound_uri自定义铃声
notify_foreground前台是否弹出
flow_control平滑推送速度
jobkey消息去重 key

参考文档