[−][src]Struct a2::request::notification::PlainNotificationBuilder
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]
fn build(
self,
device_token: &'a str,
options: NotificationOptions<'a>
) -> Payload<'a>
[src]
self,
device_token: &'a str,
options: NotificationOptions<'a>
) -> Payload<'a>
Auto Trait Implementations
impl<'a> Send for PlainNotificationBuilder<'a>
impl<'a> Unpin for PlainNotificationBuilder<'a>
impl<'a> Sync for PlainNotificationBuilder<'a>
impl<'a> UnwindSafe for PlainNotificationBuilder<'a>
impl<'a> RefUnwindSafe for PlainNotificationBuilder<'a>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,