firebae_cm/
lib.rs

1/*!
2This crate is a Rust wrapper around the Firebase Cloud Messaging V1 protocol.
3This allows you to create cloud messages in pure Rust code and send them via push messages to other devices.
4
5It is highly recommended to read the [Firebase documentation](https://firebase.google.com/docs/cloud-messaging).
6In order for this to work, you need a Google Cloud Platform account and Firebase to be setup.
7
8# Usage
9This crate can be found [on crates.io](https://crates.io/crates/firebae-cm),
10so you can use it by adding `firebae-cm` to your project's `Cargo.toml`.
11
12# Example
13```rust
14use firebae_cm::{
15    Client,
16    Error,
17    Message,
18    MessageBody,
19    Receiver,
20};
21
22#[tokio::main]
23async fn main() {
24    let token = "your_jwt_token";
25
26    // Define the receiver mode (Token, Topic or Condition).
27    let receivers = Receiver::topic("subscribers");
28
29    // Create an empty message to your receiver(s).
30    let body = MessageBody::new(receivers);
31
32    // Finalize the message with the correct url and authentication.
33    let message = Message::new("project_id", token, body);
34
35    // Create a client and send the data.
36    let client = Client::new();
37    let response: Result<String, Error> = client.send(message).await;
38    println!("{:?}", response);
39}
40```
41
42# Features
43* **oauth** - Enables automatic OAuth authentication.
44You will still need Firebase to be setup correctly and the path to a
45valid `credentials.json` file in the `GOOGLE_APPLICATION_CREDENTIALS`
46environment variable. Then, creating a message can be done using `Message::with_oauth("project_id", body).await?`.
47*/
48
49#![cfg_attr(docsrs, feature(doc_cfg))]
50
51mod client;
52pub use client::*;
53
54mod message;
55pub use message::*;
56
57mod notification;
58pub use notification::*;
59
60mod settings;
61pub use settings::*;
62
63mod utils;
64pub use utils::*;
65
66pub use firebae_derive::*;