Crates.io | apns2 |
lib.rs | apns2 |
version | 0.1.0 |
source | src |
created_at | 2018-02-25 12:25:34.018684 |
updated_at | 2018-02-25 12:25:34.018684 |
description | Apple Push Notification Service (apns) client library |
homepage | |
repository | https://github.com/theduke/apns2-rust |
max_upload_size | |
id | 52783 |
size | 35,785 |
A Rust crate for sending push notifications to iOS devices via the APNS http/2 API.
Cargo.toml:
[dependencies]
apns2 = "*"
failure = "*"
extern crate apns2;
extern crate failure;
use failure::Error;
fn send(device_token: String, alert: String) -> Result<(), Error> {
let apns = apns2::Apns::with_certificate(
"certs/apns_cert.p12", // Path to p12 certificate + key db file.
Some("passphrase".to_string()), // Passphraase used for the p12 file.
)?;
let notification = NotificationBuilder::new(topic, token)
.title("title")
.body("body")
.sound("somesound.mp3")
.badge(5)
.build();
apns.send(n)?;
Ok(())
}
Sadly, no native http/2 Rust libraries are mature enough to be used, so this crate currently uses cURL via rust-curl. Once the ecosystem catches up, a native Rust solution will be used.
This library is dual-licensed under Apache and MIT.
Check the license files in this repo for details.