Crate fcm [−] [src]
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().unwrap(); let mut map = HashMap::new(); map.insert("message", "Howdy!"); let mut builder = fcm::MessageBuilder::new("<FCM API Key>", "<registration id>"); builder.data(&map); let payload = builder.finalize(); tokio::run(lazy(move || { client .send(payload) .map(|response| { println!("Sent: {:?}", response); }).map_err(|error| { println!("Error: {:?}", error) }) }));
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().unwrap(); 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 payload = message_builder.finalize(); tokio::run(lazy(move || { client .send(payload) .map(|response| { println!("Sent: {:?}", response); }).map_err(|error| { println!("Error: {:?}", error) }) }));
Modules
response |
Structs
Client | |
DateTime |
ISO 8601 combined date and time with time zone. |
Duration |
ISO 8601 time duration with nanosecond precision. This also allows for the negative duration; see individual methods for details. |
FcmResponse | |
FixedOffset |
The time zone with fixed offset, from UTC-23:59:59 to UTC+23:59:59. |
FutureResponse | |
Message |
Represents a FCM message. Construct the FCM message using various utility methods and finally send it. |
MessageBody | |
MessageBuilder |
A builder to get a |
MessageResult | |
Notification |
This struct represents a FCM notification. Use the
corresponding |
NotificationBuilder |
A builder to get a |
Enums
Error | |
FcmError | |
Priority | |
RetryAfter |
Traits
Service |
An asynchronous function from |