pub struct PlainNotificationBuilder<'a> { /* fields omitted */ }
A builder to create a simple APNs notification payload.
let mut builder = PlainNotificationBuilder::new("Hi there");
builder.set_badge(420);
builder.set_category("cat1");
builder.set_sound("prööt");
let payload = builder.build("device_id", Default::default())
.to_json_string().unwrap();
Creates a new builder with the minimum amount of content.
let payload = PlainNotificationBuilder::new("a body")
.build("token", Default::default());
assert_eq!(
"{\"aps\":{\"alert\":\"a body\"}}",
&payload.to_json_string().unwrap()
);
A number to show on a badge on top of the app icon.
let mut builder = PlainNotificationBuilder::new("a body");
builder.set_badge(4);
let payload = builder.build("token", Default::default());
assert_eq!(
"{\"aps\":{\"alert\":\"a body\",\"badge\":4}}",
&payload.to_json_string().unwrap()
);
File name of the custom sound to play when receiving the notification.
let mut builder = PlainNotificationBuilder::new("a body");
builder.set_sound("meow");
let payload = builder.build("token", Default::default());
assert_eq!(
"{\"aps\":{\"alert\":\"a body\",\"sound\":\"meow\"}}",
&payload.to_json_string().unwrap()
);
When a notification includes the category key, the system displays the
actions for that category as buttons in the banner or alert interface.
let mut builder = PlainNotificationBuilder::new("a body");
builder.set_category("cat1");
let payload = builder.build("token", Default::default());
assert_eq!(
"{\"aps\":{\"alert\":\"a body\",\"category\":\"cat1\"}}",
&payload.to_json_string().unwrap()
);
Generates the request payload to be send with the Client
.