Struct fcm::MessageBuilder[][src]

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

A builder to get a Message instance.

Examples

use fcm::MessageBuilder;

let mut builder = MessageBuilder::new("<FCM API Key>", "<registration id>");
builder.dry_run(true);
let message = builder.finalize();

Implementations

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

pub fn new(api_key: &'a str, to: &'a str) -> Self[src]

Get a new instance of Message. You need to supply to.

pub fn new_multi<S>(api_key: &'a str, ids: &'a [S]) -> Self where
    S: Into<Cow<'a, str>> + AsRef<str>, 
[src]

Get a new instance of Message. You need to supply registration ids.

pub fn registration_ids<S>(&mut self, ids: &'a [S]) -> &mut Self where
    S: Into<Cow<'a, str>> + AsRef<str>, 
[src]

String value to replace format specifiers in the body string.

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

Set this parameter to identify groups of messages that can be collapsed.

pub fn priority(&mut self, priority: Priority) -> &mut Self[src]

Set the priority of the message. You can set Normal or High priorities.

Examples:

use fcm::{MessageBuilder, Priority};

let mut builder = MessageBuilder::new("<FCM API Key>", "<registration id>");
builder.priority(Priority::High);
let message = builder.finalize();

pub fn content_available(&mut self, content_available: bool) -> &mut Self[src]

To set the content-available field on iOS

pub fn delay_while_idle(&mut self, delay_while_idle: bool) -> &mut Self[src]

When set to true, sends the message only when the device is active.

pub fn time_to_live(&mut self, time_to_live: i32) -> &mut Self[src]

How long (in seconds) to keep the message on FCM servers in case the device is offline. The maximum and default is 4 weeks.

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

Package name of the application where the registration tokens must match.

pub fn dry_run(&mut self, dry_run: bool) -> &mut Self[src]

When set to true, allows you to test FCM without actually sending the message.

pub fn data(&mut self, data: &dyn Serialize) -> Result<&mut Self, Error>[src]

Use this to add custom key-value pairs to the message. This data must be handled appropriately on the client end. The data can be anything that Serde can serialize to JSON.

Examples:

use fcm::MessageBuilder;
use std::collections::HashMap;

let mut map = HashMap::new();
map.insert("message", "Howdy!");

let mut builder = MessageBuilder::new("<FCM API Key>", "<registration id>");
builder.data(&map);
let message = builder.finalize();

pub fn notification(&mut self, notification: Notification<'a>) -> &mut Self[src]

Use this to set a Notification for the message.

Examples:

use fcm::{MessageBuilder, NotificationBuilder};

let mut builder = NotificationBuilder::new();
builder.title("Hey!");
builder.body("Do you want to catch up later?");
let notification = builder.finalize();

let mut builder = MessageBuilder::new("<FCM API Key>", "<registration id>");
builder.notification(notification);
let message = builder.finalize();

pub fn finalize(self) -> Message<'a>[src]

Complete the build and get a Message instance

Trait Implementations

impl<'a> Debug for MessageBuilder<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for MessageBuilder<'a>

impl<'a> Send for MessageBuilder<'a>

impl<'a> Sync for MessageBuilder<'a>

impl<'a> Unpin for MessageBuilder<'a>

impl<'a> UnwindSafe for MessageBuilder<'a>

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> Instrument 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.