9 releases
new 0.1.9 | Feb 20, 2025 |
---|---|
0.1.8 | Feb 20, 2025 |
#340 in Cryptography
342 downloads per month
74KB
584 lines
Bark library for Rust
Overview
This library is for someone developed in Rust for sending push notifications to iOS devices which has installed the Bark app.
The message is directly sent to APNS server, so it is very fast and safe.
And the message can be sent in encrypted mode, that means APNS can not see the content of the message.
Key Features
- Multi-Device Support: Send notifications to multiple iOS devices simultaneously.
- Customizable Notifications: Set custom titles and messages for your notifications.
- Secure Communication: Utilizes Apple Push Notification service (APNs) with JWT authentication.
Technical Details
- Language: Rust
- Dependencies:
openssl
: For cryptographic operations and JWT token generationreqwest
: For making HTTP requests to the APNs serverstokio
: For asynchronous I/O operations
Example Usage
first add dependencies
cargo add bark-dev
send a simple message
let mut bark = bark::Bark::new();
let msg = bark::Message::new("title", "body");
let resp = bark.send(msg);
let devices = [String::from("device_token_get_from_bark_app")];
let send_result = bark.send(&msg, devices);
if let Some(failed_device) = send_result {
println!("Failed to send to device: {}", failed_device);
}
send a encrypted message
let mut bark = bark::Bark::new();
let mut msg = bark::Message::new("title", "body");
msg.set_enc_type(bark_dev::msg::EncryptType::AES192);
msg.set_mode(bark_dev::msg::EncryptMode::ECB);
msg.set_key("the_key_must_the_same_as_bark_app");
// if you not set iv it will generate a random iv and send it to the server
msg.set_iv("the_iv_must_the_same_as_bark_app");
let resp = bark.send(msg);
let devices = [String::from("device_token_get_from_bark_app")];
let send_result = bark.send(&msg, devices);
if let Some(failed_device) = send_result {
println!("Failed to send to device: {}", failed_device);
}
async send a message
let mut bark = bark::Bark::new();
let msg = bark::Message::new("title", "body");
let devices = [String::from("device_token_get_from_bark_app")];
let send_result = bark.async_send(&msg, devices).await?;
if let Some(failed_device) = send_result {
println!("Failed to send to device: {}", failed_device);
}
known issue
- not all param support in encrypt mode detail in code
Dependencies
~7–19MB
~261K SLoC