Struct a2::SilentNotificationBuilder[][src]

pub struct SilentNotificationBuilder { /* fields omitted */ }
Expand description

A builder to create an APNs silent notification payload which can be used to send custom data to the user’s phone if the user hasn’t been running the app for a while. The custom data needs to be implementing Serialize from Serde.

Example

let mut test_data = HashMap::new();
test_data.insert("a", "value");

let mut payload = SilentNotificationBuilder::new()
   .build("device_id", Default::default());

payload.add_custom_data("custom", &test_data);

assert_eq!(
    "{\"aps\":{\"content-available\":1},\"custom\":{\"a\":\"value\"}}",
    &payload.to_json_string().unwrap()
);

Implementations

Creates a new builder.

let payload = SilentNotificationBuilder::new()
    .build("token", Default::default());

assert_eq!(
    "{\"aps\":{\"content-available\":1}}",
    &payload.to_json_string().unwrap()
);

Trait Implementations

Returns the “default value” for a type. Read more

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