6 releases
0.2.4 | Jul 29, 2024 |
---|---|
0.2.3 | Jul 28, 2024 |
0.1.0 | Jul 27, 2024 |
#9 in #notification-service
10KB
84 lines
apnrs
apnrs
is a Rust library for sending push notifications to Apple devices using the Apple Push Notification service (APNs).
This crate provides utilities for creating the required payloads and sending the push notifications.
Usage
extern crate apnrs;
use apnrs::{send_push_notification, ApnsPayload, Aps};
#[tokio::main]
async fn main() {
let payload = ApnsPayload {
aps: Aps {
alert: "Hello, world!".to_string(),
content_available: 1,
badge: Some(1),
sound: Some("default".to_string()),
category: None,
thread_id: None,
},
custom_key: Some("custom_value".to_string()),
};
let response = send_push_notification(
"path/to/auth/key",
"TEAM_ID",
"KEY_ID",
"DEVICE_TOKEN",
"com.example.app",
payload,
true
).await;
match response {
Ok(res) => println!("Notification sent: {:?}", res),
Err(e) => eprintln!("Error sending notification: {:?}", e),
}
}
License
This project is licensed under the MIT License.
Dependencies
~17–32MB
~588K SLoC