19 个版本

0.9.2 2022 年 7 月 27 日
0.9.1 2021 年 3 月 26 日
0.8.1 2020 年 12 月 31 日
0.7.1 2019 年 12 月 17 日
0.1.1 2016 年 5 月 22 日

#7#通知

Download history • Rust 包仓库 768/week @ 2024-03-14 • Rust 包仓库 1772/week @ 2024-03-21 • Rust 包仓库 1429/week @ 2024-03-28 • Rust 包仓库 2356/week @ 2024-04-04 • Rust 包仓库 1948/week @ 2024-04-11 • Rust 包仓库 1444/week @ 2024-04-18 • Rust 包仓库 1585/week @ 2024-04-25 • Rust 包仓库 905/week @ 2024-05-02 • Rust 包仓库 1252/week @ 2024-05-09 • Rust 包仓库 1435/week @ 2024-05-16 • Rust 包仓库 1597/week @ 2024-05-23 • Rust 包仓库 1565/week @ 2024-05-30 • Rust 包仓库 717/week @ 2024-06-06 • Rust 包仓库 462/week @ 2024-06-13 • Rust 包仓库 322/week @ 2024-06-20 • Rust 包仓库 144/week @ 2024-06-27 • Rust 包仓库

2,136 每月下载量
4 crates 中使用

MIT 许可证

43KB
778

fcm

Cargo tests Coveralls Crates.io Version Crates.io Downloads Crates.io License

Matrix 聊天

需求

需要 Tokio 执行器版本 1.0 或更高版本以及 Rust 编译器版本 1.45.0 或更高版本。

示例

查看示例目录以获取简单的发送者。


lib.rs:

fcm

用于异步发送 Firebase 云消息或推送通知的客户端。

示例

要发送带有一些自定义数据的 FCM 消息

let client = fcm::Client::new();

let mut map = HashMap::new();
map.insert("message", "Howdy!");

let mut builder = fcm::MessageBuilder::new("<FCM API Key>", "<registration id>");
builder.data(&map);

let response = client.send(builder.finalize()).await?;
println!("Sent: {:?}", response);

要使用 FCM 通知发送消息,我们首先构建通知

let mut builder = fcm::NotificationBuilder::new();
builder.title("Hey!");
builder.body("Do you want to catch up later?");
let notification = builder.finalize();

然后在消息中设置它,在发送之前

let client = fcm::Client::new();

let mut notification_builder = fcm::NotificationBuilder::new();
notification_builder.title("Hey!");
notification_builder.body("Do you want to catch up later?");

let notification = notification_builder.finalize();
let mut message_builder = fcm::MessageBuilder::new("<FCM API Key>", "<registration id>");
message_builder.notification(notification);

let response = client.send(message_builder.finalize()).await?;
println!("Sent: {:?}", response);

依赖项

~5–22MB
~318K SLoC