3 releases
new 0.1.2 | Jan 30, 2025 |
---|---|
0.1.1 | Jan 30, 2025 |
0.1.0 | Jan 30, 2025 |
#4 in #fcm
37 downloads per month
11KB
135 lines
fcm_notification
A Rust library for sending Firebase Cloud Messaging (FCM) notifications.
Installation
Add the following to your Cargo.toml
:
[dependencies]
fcm-notification = "0.1.2"
Usage
use fcm_notification::{FcmNotification, NotificationPayload};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let fcm = FcmNotification::new("service_account.json")?;
let notification = NotificationPayload {
token: "device-token-here",
title: "New Like",
body: "Someone liked your post!",
data: None,
};
fcm.send_notification(¬ification).await?;
Ok(())
}
License
This project is licensed under the MIT License.
lib.rs
:
A Rust library for sending Firebase Cloud Messaging (FCM) notifications.
This crate provides a simple interface to send push notifications using Firebase Cloud Messaging (FCM). It handles authentication with Google OAuth2 and constructs the necessary payloads for FCM requests.
Example
use fcm_notification::{FcmNotification, NotificationPayload};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let fcm = FcmNotification::new("service_account.json")?;
let notification = NotificationPayload {
token: "device-token-here",
title: "New Like",
body: "Someone liked your post!",
data: None,
};
fcm.send_notification(¬ification).await?;
Ok(())
}
Dependencies
~13–26MB
~479K SLoC