Crates.io | firebae-cm |
lib.rs | firebae-cm |
version | 0.4.2 |
source | src |
created_at | 2022-03-10 17:31:27.875204 |
updated_at | 2023-03-29 13:22:04.094233 |
description | A Firebase Cloud Messaging Http V1 implementation |
homepage | https://github.com/Vesafary/firebae-cm |
repository | https://github.com/Vesafary/firebae-cm |
max_upload_size | |
id | 547709 |
size | 43,517 |
Rust crate for Firebase Cloud Messaging Http V1
I recommend to read up on FCM before attempting to use this crate.
What | Where |
---|---|
Basic information on FCM | https://firebase.google.com/docs/cloud-messaging |
Used data structure | https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages |
use firebae_cm::{Client, Message, MessageBody, Receiver};
async fn send_message() {
// Setup message
let receiver = Receiver::topic("subscribers");
let empty_body = MessageBody::new(receiver);
let message = Message::new("your_project_id", "your_jwt_token", empty_body);
// Create client and send message
let client = Client::new();
let res: Result<String, firebae_cm::Error> = client.send(message).await;
}
This will result in a post request to
https://fcm.googleapis.com/v1/projects/your_project_id/messages:send
with the appropriate Authentication: Bearer your_jwt_token
header
and the following body:
{
"message":{
"topic":"subscribers",
}
}
For more useful examples, see the examples folder.