Crate fcm_http1

Source
Expand description

§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_http1::Client::new();

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

let mut builder = fcm_http1::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_http1::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_http1::Client::new();

let mut notification_builder = fcm_http1::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_http1::MessageBuilder::new("<FCM API Key>", "<registration id>");
message_builder.notification(notification);

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

Modules§

response

Structs§

Client
An async client for sending the notification payload.
DateTime
ISO 8601 combined date and time with time zone.
FcmResponse
FixedOffset
The time zone with fixed offset, from UTC-23:59:59 to UTC+23:59:59.
Message
Represents a FCM message. Construct the FCM message using various utility methods and finally send it.
MessageBody
MessageBuilder
A builder to get a Message instance.
MessageResult
Notification
This struct represents a FCM notification. Use the corresponding NotificationBuilder to get an instance. You can then use this notification instance when sending a FCM message.
NotificationBuilder
A builder to get a Notification instance.

Enums§

Error
Fatal errors. Referred from Firebase documentation
ErrorReason
A description of what went wrong with the push notification. Referred from Firebase documentation
FcmError
Fatal errors. Referred from Firebase documentation
Priority
RetryAfter

Type Aliases§

Duration
Alias of TimeDelta.