pub struct Message {
pub target: Target,
pub notification: Option<Notification>,
pub data: HashMap<String, String>,
pub android: Option<AndroidConfig>,
pub apns: Option<ApnsConfig>,
pub webpush: Option<WebpushConfig>,
}Expand description
A message to send via Firebase Cloud Messaging.
Exactly one of Self::target must be set to a token, topic, or
condition — this is enforced by Target being a single field rather
than three optional ones.
Fields§
§target: TargetWho the message is delivered to.
notification: Option<Notification>A simple, display notification shown by the client’s OS.
data: HashMap<String, String>Custom key-value payload delivered to the client app.
android: Option<AndroidConfig>Android-specific delivery options.
apns: Option<ApnsConfig>Apple Push Notification Service-specific delivery options, as a raw
APNs payload (aps dictionary and custom keys).
webpush: Option<WebpushConfig>Web Push-specific delivery options.
Implementations§
Source§impl Message
impl Message
Sourcepub fn to_token(token: impl Into<String>) -> Self
pub fn to_token(token: impl Into<String>) -> Self
Starts building a message addressed to a single device registration token.
Sourcepub fn to_topic(topic: impl Into<String>) -> Self
pub fn to_topic(topic: impl Into<String>) -> Self
Starts building a message addressed to a topic.
Sourcepub fn to_condition(condition: impl Into<String>) -> Self
pub fn to_condition(condition: impl Into<String>) -> Self
Starts building a message addressed to devices matching a topic
condition expression, e.g. "'A' in topics && 'B' in topics".
Sourcepub fn with_notification(self, notification: Notification) -> Self
pub fn with_notification(self, notification: Notification) -> Self
Sets a display notification.
Sourcepub fn with_data(self, data: HashMap<String, String>) -> Self
pub fn with_data(self, data: HashMap<String, String>) -> Self
Sets the custom data payload, replacing any previous value.
Sourcepub fn with_android(self, android: AndroidConfig) -> Self
pub fn with_android(self, android: AndroidConfig) -> Self
Sets Android-specific delivery options.
Sourcepub fn with_apns(self, apns: ApnsConfig) -> Self
pub fn with_apns(self, apns: ApnsConfig) -> Self
Sets APNs-specific delivery options.
Sourcepub fn with_webpush(self, webpush: WebpushConfig) -> Self
pub fn with_webpush(self, webpush: WebpushConfig) -> Self
Sets Web Push-specific delivery options.