Struct a2::WebNotificationBuilder[][src]

pub struct WebNotificationBuilder<'a> { /* fields omitted */ }
Expand description

A builder to create a simple APNs notification payload.

Example

let mut builder = WebNotificationBuilder::new(WebPushAlert {title: "Hello", body: "World", action: "View"}, &["arg1"]);
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 mut builder = WebNotificationBuilder::new(WebPushAlert {title: "Hello", body: "World", action: "View"}, &["arg1"]);
let payload = builder.build("token", Default::default());

assert_eq!(
    "{\"aps\":{\"alert\":{\"action\":\"View\",\"body\":\"World\",\"title\":\"Hello\"},\"url-args\":[\"arg1\"]}}",
    &payload.to_json_string().unwrap()
);

File name of the custom sound to play when receiving the notification.

let mut builder = WebNotificationBuilder::new(WebPushAlert {title: "Hello", body: "World", action: "View"}, &["arg1"]);
builder.set_sound("meow");
let payload = builder.build("token", Default::default());

assert_eq!(
    "{\"aps\":{\"alert\":{\"action\":\"View\",\"body\":\"World\",\"title\":\"Hello\"},\"sound\":\"meow\",\"url-args\":[\"arg1\"]}}",
    &payload.to_json_string().unwrap()
);

Trait Implementations

Generates the request payload to be send with the Client.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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