1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! Direct APNs client for sending [Bark](https://github.com/Finb/Bark)
//! notifications.
//!
//! This crate talks to Apple Push Notification service directly with an iOS
//! device token. It does not call a Bark server, but it keeps Bark's payload
//! semantics: fields such as `title`, `body`, `markdown`, `sound`, `group`,
//! `isArchive`, `id`, and `delete` are encoded the way Bark's notification
//! service extension expects them.
//!
//! # Examples
//!
//! ## Send a Simple Message
//!
//! ```no_run
//! use bark_apns::{Bark, Message};
//!
//! fn main() -> bark_apns::Result<()> {
//! let bark = Bark::new()?;
//! let message = Message::new()
//! .title("Deploy")
//! .body("done")
//! .group("ops");
//!
//! bark.send(&message, ["device-token-from-bark-app"])?;
//! Ok(())
//! }
//! ```
//!
//! ## Send a Markdown Message
//!
//! ```no_run
//! use bark_apns::{Bark, Message};
//!
//! fn main() -> bark_apns::Result<()> {
//! let bark = Bark::new()?;
//! let message = Message::new()
//! .title("Deploy")
//! .markdown("## Deploy\n\n- status: **done**\n- target: `production`");
//!
//! bark.send(&message, ["device-token-from-bark-app"])?;
//! Ok(())
//! }
//! ```
//!
//! ## Send an Encrypted Message
//!
//! ```no_run
//! use bark_apns::{Bark, Encryption, EncryptionAlgorithm, EncryptionMode, Message};
//!
//! fn main() -> bark_apns::Result<()> {
//! let bark = Bark::new()?;
//! let encryption = Encryption::new(
//! EncryptionAlgorithm::AES128,
//! EncryptionMode::CBC,
//! "1234567890123456",
//! )?;
//!
//! let message = Message::new()
//! .title("Deploy")
//! .body("done")
//! .markdown("**Deploy** finished")
//! .group("ops")
//! .encryption(encryption);
//!
//! bark.send(&message, ["device-token-from-bark-app"])?;
//! Ok(())
//! }
//! ```
//!
//! # Notes
//!
//! - `markdown` follows Bark's documented behavior: when present, Bark renders it
//! and ignores `body` for display.
//! - Bark parses Markdown with Apple's Swift Markdown package and its own
//! renderer. It supports paragraphs, headings, block quotes, bold, italic,
//! strikethrough, inline code, code blocks, links, images, ordered and
//! unordered lists, nested lists, task-list checkboxes, soft breaks, and hard
//! line breaks. In notification banners, Bark uses the rendered plain-text body
//! and collapses repeated blank lines, so styling such as bold, italic, link
//! color, and code font is not preserved there.
//! - Encrypted pushes serialize Bark request fields to JSON, encrypt that JSON,
//! and put the result in the top-level `ciphertext` field. CBC and GCM pushes
//! also include a top-level `iv`, matching Bark's client-side decryptor.
pub use Bark;
pub use ;
pub use ;
pub use ;