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();
Methods
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 either a registration id, or a topic (/topics/...).
ⓘImportant traits for &'a mut Wpub fn registration_ids<S>(&mut self, ids: &'a [S]) -> &mut Self where
S: Into<Cow<'a, str>> + AsRef<str>,
[src]
S: Into<Cow<'a, str>> + AsRef<str>,
String value to replace format specifiers in the body string.
ⓘImportant traits for &'a mut Wpub fn collapse_key(&mut self, collapse_key: &'a str) -> &mut Self
[src]
Set this parameter to identify groups of messages that can be collapsed.
ⓘImportant traits for &'a mut Wpub 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();
ⓘImportant traits for &'a mut Wpub fn content_available(&mut self, content_available: bool) -> &mut Self
[src]
To set the content-available
field on iOS
ⓘImportant traits for &'a mut Wpub 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.
ⓘImportant traits for &'a mut Wpub 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.
ⓘImportant traits for &'a mut Wpub fn restricted_package_name(
&mut self,
restricted_package_name: &'a str
) -> &mut Self
[src]
&mut self,
restricted_package_name: &'a str
) -> &mut Self
Package name of the application where the registration tokens must match.
ⓘImportant traits for &'a mut Wpub 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: &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();
ⓘImportant traits for &'a mut Wpub 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