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

Get a new instance of Message. You need to supply either a registration id, or a topic (/topics/…).

String value to replace format specifiers in the body string.

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

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();

To set the content-available field on iOS

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

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

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

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

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();

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();

Complete the build and get a Message instance

Trait Implementations

Formats the value using the given formatter. Read more

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.