1#![warn(missing_docs)]
2
3pub mod android;
14pub mod apns;
16pub mod auth;
18mod client;
19pub mod message;
21mod result;
22pub mod webpush;
24
25pub use client::Client;
26pub use result::{Error, Result};
27
28#[cfg(test)]
29mod tests {
30 use std::{env, time::Duration};
31
32 use super::*;
33
34 #[tokio::test]
35 async fn send_simple_noti() {
36 let helloworld = "\u{202e}\u{1d5db}\u{1d5f2}\u{1d5f9}\u{1d5f9}\u{1d5fc}, world!";
37
38 let creds_path = env::var("GOOGLE_APPLICATION_CREDENTIALS").unwrap();
39 let project_id = env::var("GOOGLE_PROJECT_ID").unwrap();
40 let registration_token = env::var("FCM_REGISTRATION_TOKEN").unwrap();
41 let authenticator = auth::Authenticator::service_account_from_file(creds_path)
42 .await
43 .unwrap();
44 let client = Client::new(authenticator, project_id, true, Duration::from_secs(10));
45
46 let mut test_noti = message::Notification::default();
47 test_noti.title = Some("test notification".to_owned());
48 test_noti.body = Some(helloworld.to_owned());
49
50 let mut test_message = message::Message::default();
51 test_message.notification = Some(test_noti);
52 test_message.token = Some(registration_token);
53
54 println!("sent:");
55 println!("{:#?}", test_message);
56 println!("received:");
57 println!("{:#?}", client.send(&test_message).await.unwrap());
58 }
59}