19 releases

0.9.2 Jul 27, 2022
0.9.1 Mar 26, 2021
0.8.1 Dec 31, 2020
0.7.1 Dec 17, 2019
0.1.1 May 22, 2016

#876 in Web programming

Download history 361/week @ 2023-12-17 283/week @ 2023-12-24 521/week @ 2023-12-31 473/week @ 2024-01-07 660/week @ 2024-01-14 667/week @ 2024-01-21 598/week @ 2024-01-28 759/week @ 2024-02-04 849/week @ 2024-02-11 765/week @ 2024-02-18 610/week @ 2024-02-25 609/week @ 2024-03-03 800/week @ 2024-03-10 1304/week @ 2024-03-17 1415/week @ 2024-03-24 1856/week @ 2024-03-31

5,400 downloads per month
Used in 4 crates

MIT license

43KB
778 lines

fcm

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

Matrix chat

Requirements

Needs a Tokio executor version 1.0 or later and Rust compiler version 1.45.0 or later.

Examples

Check out the examples directory for a simple sender.


lib.rs:

fcm

A client for asynchronous sending of Firebase Cloud Messages, or Push Notifications.

Examples:

To send out a FCM Message with some custom data:

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);

To send a message using FCM Notifications, we first build the notification:

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

And then set it in the message, before sending it:

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);

Dependencies

~5–21MB
~324K SLoC