firebase:: messaging:: Message
#include <messaging.h>
Data structure used to receive messages from cloud messaging.
Summary
Constructors and Destructors | |
|---|---|
Message()Initialize the message. | |
Message(constMessage & other)Copy constructor. Makes a deep copy of thisMessage. | |
~Message()Destructor. |
Public attributes | |
|---|---|
collapse_key | std::stringThis parameter identifies a group of messages (e.g., with collapse_key: "Updates Available") that can be collapsed, so that only the last message gets sent when delivery can be resumed. |
data | std::map< std::string, std::string >The metadata, including all original key/value pairs. |
error | std::stringError code. |
error_description | std::stringHuman readable details about the error. |
from | std::stringAuthenticated ID of the sender. |
link | std::stringThe link into the app from the message. |
message_id | std::stringMessage ID. |
message_type | std::stringEquivalent with a content-type. |
notification | Optional notification to show. |
notification_opened | boolA flag indicating whether this message was opened by tapping a notification in the OS system tray. |
priority | std::stringSets the priority of the message. |
raw_data | std::vector< unsigned char >Binary payload. |
time_to_live | int32_tThis parameter specifies how long (in seconds) the message should be kept in FCM storage if the device is offline. |
to | std::stringThis parameter specifies the recipient of a message. |
Public functions | |
|---|---|
operator=(constMessage & other) | Message &Copy assignment operator. Makes a deep copy of thisMessage. |
Public attributes
collapse_key
std::stringfirebase::messaging::Message::collapse_key
This parameter identifies a group of messages (e.g., with collapse_key: "Updates Available") that can be collapsed, so that only the last message gets sent when delivery can be resumed.
This is intended to avoid sending too many of the same messages when the device comes back online or becomes active.
Note that there is no guarantee of the order in which messages get sent.
Note: A maximum of 4 different collapse keys is allowed at any given time. This means a FCM connection server can simultaneously store 4 different send-to-sync messages per client app. If you exceed this number, there is no guarantee which 4 collapse keys the FCM connection server will keep.
data
std::map<std::string,std::string>firebase::messaging::Message::data
The metadata, including all original key/value pairs.
Includes some of the HTTP headers used when sending the message.gcm,google andgoog prefixes are reserved for internal use.
error
std::stringfirebase::messaging::Message::error
Error code.
Used in "nack" messages for CCS, and in responses from the server. See the CCS specification for the externally-supported list.
error_description
std::stringfirebase::messaging::Message::error_description
Human readable details about the error.
from
std::stringfirebase::messaging::Message::from
Authenticated ID of the sender.
This is a project number in most cases.
Any value starting with google.com, goog. or gcm. are reserved.
link
std::stringfirebase::messaging::Message::link
The link into the app from the message.
message_id
std::stringfirebase::messaging::Message::message_id
Message ID.
This can be specified by sender. Internally a hash of the message ID and other elements will be used for storage. The ID must be unique for each topic subscription - using the same ID may result in overriding the original message or duplicate delivery.
message_type
std::stringfirebase::messaging::Message::message_type
Equivalent with a content-type.
Defined values:
- "deleted_messages" - indicates the server had too many messages and dropped some, and the client should sync with his own server. Current limit is 100 messages stored.
- "send_event" - indicates an upstream message has been pushed to the FCM server. It does not guarantee the upstream destination received it. Parameters: "message_id"
- "send_error" - indicates an upstream message expired, without being sent to the FCM server. Parameters: "message_id" and "error"
If this field is missing, the message is a regular message.
notification
Notification*firebase::messaging::Message::notification
Optional notification to show.
This only set if a notification was received with this message, otherwise it is null.
The notification is only guaranteed to be valid during the call toListener::OnMessage(). If you need to keep it around longer you will need to make a copy of either theMessage orNotification. Copying theMessage object implicitly makes a deep copy of the notification (allocated with new) which is owned by theMessage.
notification_opened
boolfirebase::messaging::Message::notification_opened
A flag indicating whether this message was opened by tapping a notification in the OS system tray.
If the message was received this way this flag is set to true.
priority
std::stringfirebase::messaging::Message::priority
Sets the priority of the message.
Valid values are "normal" and "high." On iOS and tvOS, these correspond to APNs priority 5 and 10.
By default, messages are sent with normal priority. Normal priority optimizes the client app's battery consumption, and should be used unless immediate delivery is required. For messages with normal priority, the app may receive the message with unspecified delay.
When a message is sent with high priority, it is sent immediately, and the app can wake a sleeping device and open a network connection to your server.
For more information, seeSetting the priority of a message.
raw_data
std::vector<unsignedchar>firebase::messaging::Message::raw_data
Binary payload.
time_to_live
int32_tfirebase::messaging::Message::time_to_live
This parameter specifies how long (in seconds) the message should be kept in FCM storage if the device is offline.
The maximum time to live supported is 4 weeks, and the default value is 4 weeks. For more information, seeSetting the lifespan of a message.
to
std::stringfirebase::messaging::Message::to
This parameter specifies the recipient of a message.
For example it can be a registration token, a topic name, an Instance ID or project ID.
PROJECT_ID@gcm.googleapis.com or Instance ID are accepted.
Public functions
Message
firebase::messaging::Message::Message()
Initialize the message.
Message
firebase::messaging::Message::Message(constMessage&other)
Copy constructor. Makes a deep copy of thisMessage.
operator=
Message&firebase::messaging::Message::operator=(constMessage&other)
Copy assignment operator. Makes a deep copy of thisMessage.
~Message
firebase::messaging::Message::~Message()
Destructor.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-26 UTC.