Struct a2::PlainNotificationBuilder [−][src]
pub struct PlainNotificationBuilder<'a> { /* fields omitted */ }
Expand description
A builder to create a simple APNs notification payload.
Example
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();
Implementations
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()
);
Trait Implementations
Generates the request payload to be send with the Client
.
Auto Trait Implementations
impl<'a> RefUnwindSafe for PlainNotificationBuilder<'a>
impl<'a> Send for PlainNotificationBuilder<'a>
impl<'a> Sync for PlainNotificationBuilder<'a>
impl<'a> Unpin for PlainNotificationBuilder<'a>
impl<'a> UnwindSafe for PlainNotificationBuilder<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more