[][src]Struct a2::PlainNotificationBuilder

pub struct PlainNotificationBuilder<'a> { /* fields omitted */ }

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();

Methods

impl<'a> PlainNotificationBuilder<'a>[src]

pub fn new(body: &'a str) -> PlainNotificationBuilder<'a>[src]

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()
);

pub fn set_badge(&mut self, badge: u32) -> &mut Self[src]

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()
);

pub fn set_sound(&mut self, sound: &'a str) -> &mut Self[src]

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()
);

pub fn set_category(&mut self, category: &'a str) -> &mut Self[src]

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

impl<'a> NotificationBuilder<'a> for PlainNotificationBuilder<'a>[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.