Struct fcm::MessageBuilder
source · [−]pub struct MessageBuilder<'a> { /* private fields */ }
Expand description
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
sourceimpl<'a> MessageBuilder<'a>
impl<'a> MessageBuilder<'a>
sourcepub fn new(api_key: &'a str, to: &'a str) -> Self
pub fn new(api_key: &'a str, to: &'a str) -> Self
Get a new instance of Message. You need to supply to.
sourcepub fn new_multi<S>(api_key: &'a str, ids: &'a [S]) -> Self where
S: Into<Cow<'a, str>> + AsRef<str>,
pub fn new_multi<S>(api_key: &'a str, ids: &'a [S]) -> Self where
S: Into<Cow<'a, str>> + AsRef<str>,
Get a new instance of Message. You need to supply registration ids.
sourcepub fn registration_ids<S>(&mut self, ids: &'a [S]) -> &mut Self where
S: Into<Cow<'a, str>> + AsRef<str>,
pub fn registration_ids<S>(&mut self, ids: &'a [S]) -> &mut Self where
S: Into<Cow<'a, str>> + AsRef<str>,
String value to replace format specifiers in the body string.
sourcepub fn collapse_key(&mut self, collapse_key: &'a str) -> &mut Self
pub fn collapse_key(&mut self, collapse_key: &'a str) -> &mut Self
Set this parameter to identify groups of messages that can be collapsed.
sourcepub fn priority(&mut self, priority: Priority) -> &mut Self
pub fn priority(&mut self, priority: Priority) -> &mut Self
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();
sourcepub fn content_available(&mut self, content_available: bool) -> &mut Self
pub fn content_available(&mut self, content_available: bool) -> &mut Self
To set the content-available
field on iOS
sourcepub fn delay_while_idle(&mut self, delay_while_idle: bool) -> &mut Self
pub fn delay_while_idle(&mut self, delay_while_idle: bool) -> &mut Self
When set to true
, sends the message only when the device is active.
sourcepub fn time_to_live(&mut self, time_to_live: i32) -> &mut Self
pub fn time_to_live(&mut self, time_to_live: i32) -> &mut Self
How long (in seconds) to keep the message on FCM servers in case the device is offline. The maximum and default is 4 weeks.
sourcepub fn restricted_package_name(
&mut self,
restricted_package_name: &'a str
) -> &mut Self
pub fn restricted_package_name(
&mut self,
restricted_package_name: &'a str
) -> &mut Self
Package name of the application where the registration tokens must match.
sourcepub fn dry_run(&mut self, dry_run: bool) -> &mut Self
pub fn dry_run(&mut self, dry_run: bool) -> &mut Self
When set to true
, allows you to test FCM without actually sending the message.
sourcepub fn data(&mut self, data: &dyn Serialize) -> Result<&mut Self, Error>
pub fn data(&mut self, data: &dyn Serialize) -> Result<&mut Self, Error>
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();
sourcepub fn notification(&mut self, notification: Notification<'a>) -> &mut Self
pub fn notification(&mut self, notification: Notification<'a>) -> &mut Self
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();
sourcepub fn mutable_content(&mut self, mutable_content: bool) -> &mut Self
pub fn mutable_content(&mut self, mutable_content: bool) -> &mut Self
To set the mutable_content
field on iOS
Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more