Expand description
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_service::{FcmNotificationService, NotificationPayload};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let fcm_service = FcmNotificationService::new("service_account.json")?;
let notification = NotificationPayload {
token: "device-token-here",
title: "New Like",
body: "Someone liked your post!",
data: None,
};
fcm_service.send_notification(¬ification).await?;
Ok(())
}Structs§
- FcmNotification
Service - The main service for sending FCM notifications.
- Notification
Payload - Represents the payload for an FCM notification.
- Service
Account - Represents a Firebase service account, loaded from a JSON file.
Enums§
- FcmError
- Represents errors that can occur while using the
FcmNotificationService.