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
impl<'a> RefUnwindSafe for WebNotificationBuilder<'a>
impl<'a> Send for WebNotificationBuilder<'a>
impl<'a> Sync for WebNotificationBuilder<'a>
impl<'a> Unpin for WebNotificationBuilder<'a>
impl<'a> UnwindSafe for WebNotificationBuilder<'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