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
The collapse key used for collapsible messages.
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.
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
Priority level.
raw_data
std::string
Binary payload.
time_to_live
int32_t
Time to live, in seconds.
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

The collapse key used for collapsible messages.

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.

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.

CCS uses "ack", "nack" for flow control and error handling. "control" is used by CCS for connection control.

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 Message object implicitly makes a deep copy of the notification (allocated with new) which is owned by the Message.

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

notification_opened

bool firebase::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::string firebase::messaging::Message::priority

Priority level.

Defines values are "normal" and "high". By default messages are sent with normal priority.

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

raw_data

std::string firebase::messaging::Message::raw_data

Binary payload.

For webpush and non-json messages, this is the body of the request entity.

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

time_to_live

int32_t firebase::messaging::Message::time_to_live

Time to live, in seconds.

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

to

std::string firebase::messaging::Message::to

This parameter specifies the recipient of a message.

For example it can be a registration token, a topic name, a IID or project ID.

This field is used for both upstream messages sent with firebase::messaging:Send() and downstream messages received through Listener::OnMessage(). For upstream messages, PROJECT_ID@gcm.googleapis.com or the more general IID format are accepted.

Public functions

Message

 firebase::messaging::Message::Message()

Initialize the message.

Message

 firebase::messaging::Message::Message(
  const Message & other
)

Copy constructor. Makes a deep copy of this Message.

operator=

Message & firebase::messaging::Message::operator=(
  const Message & other
)

Copy assignment operator. Makes a deep copy of this Message.

~Message

 firebase::messaging::Message::~Message()

Destructor.

Send feedback about...

Need help? Visit our support page.