Ir a la consola

firebase::messaging::Message

#include <messaging.h>

Data structure used to send messages to, and receive messages from, cloud messaging.

Summary

Constructors and Destructors

Message()
Initialize the message.
Message(const Message & other)
Copy constructor. Makes a deep copy of this Message.
~Message()
Destructor.

Public attributes

collapse_key
std::string
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.
data
std::map< std::string, std::string >
The metadata, including all original key/value pairs.
error
std::string
Error code.
error_description
std::string
Human readable details about the error.
from
std::string
Authenticated ID of the sender.
link
std::string
The link into the app from the message.
message_id
std::string
Message ID.
message_type
std::string
Equivalent with a content-type.
notification
Optional notification to show.
notification_opened
bool
A flag indicating whether this message was opened by tapping a notification in the OS system tray.
priority
std::string
Sets the priority of the message.
raw_data
std::string
Binary payload. This field is currently unused.
time_to_live
int32_t
This parameter specifies how long (in seconds) the message should be kept in FCM storage if the device is offline.
to
std::string
This parameter specifies the recipient of a message.

Public functions

operator=(const Message & other)
Copy assignment operator. Makes a deep copy of this Message.

Public attributes

collapse_key

std::string firebase::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.

This field is only used for downstream messages received through Listener::OnMessage().

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 and goog prefixes are reserved for internal use.

This field is used for both upstream messages sent with firebase::messaging::Send() and downstream messages received through Listener::OnMessage().

error

std::string firebase::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.

This field is only used for downstream messages received through Listener::OnMessage().

error_description

std::string firebase::messaging::Message::error_description

Human readable details about the error.

This field is only used for downstream messages received through Listener::OnMessage().

from

std::string firebase::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.

This field is only used for downstream messages received through Listener::OnMessage().

link

std::string firebase::messaging::Message::link

The link into the app from the message.

This field is only used for downstream messages received through Listener::OnMessage().

message_id

std::string firebase::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.

This field is used for both upstream messages sent with firebase::messaging::Send() and downstream messages received through Listener::OnMessage().

message_type

std::string firebase::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.

This field is only used for downstream messages received through Listener::OnMessage().

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 to Listener::OnMessage(). If you need to keep it around longer you will need to make a copy of either the Message or Notification. Copying the