apnrs

Crates.ioapnrs
lib.rsapnrs
version0.2.4
sourcesrc
created_at2024-07-27 11:00:31.201064
updated_at2024-07-29 17:56:43.782006
descriptionA Rust library for sending push notifications via APNs.
homepage
repository
max_upload_size
id1317185
size10,674
(boredcoder411)

documentation

README

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.

Commit count: 0

cargo fmt