firebase::messaging

Firebase Cloud Messaging API.

Summary

Firebase Cloud Messaging allows you to send data from your server to your users' devices, and receive messages from devices on the same connection if you're using a XMPP server.

The FCM service handles all aspects of queueing of messages and delivery to client applications running on target devices.

Functions

Initialize(const App & app, Listener *listener)
Initialize Firebase Cloud Messaging.
Send(const Message & message)
void
Send an upstream ("device to cloud") message.
SetListener(Listener *listener)
Set the listener for events from the Firebase Cloud Messaging servers.
Subscribe(const char *topic)
void
Subscribe to receive all messages to the specified topic.
Terminate()
void
Terminate Firebase Cloud Messaging.
Unsubscribe(const char *topic)
void
Unsubscribe from a topic.

Classes

firebase::messaging::Listener

Base class used to receive messages from Firebase Cloud Messaging.

Structs

firebase::messaging::Message

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

firebase::messaging::Notification

Used for messages that display a notification.

Functions

Initialize

InitResult Initialize(
  const App & app,
  Listener *listener
)

Initialize Firebase Cloud Messaging.

After Initialize is called, the implementation may call functions on the Listener provided at any time.

Details
Parameters
app
The Firebase App object for this application.
listener
A Listener object that listens for events from the Firebase Cloud Messaging servers.
Returns
kInitResultSuccess if initialization succeeded, or kInitResultFailedMissingDependency on Android if Google Play services is not available on the current device.

Send

void Send(
  const Message & message
)

Send an upstream ("device to cloud") message.

You can only use the upstream feature if your FCM implementation uses the XMPP-based Cloud Connection Server. The current limits for max storage time and number of outstanding messages per application are documented in the FCM Developers Guide.

Details
Parameters
message
The message to send upstream.

SetListener

Listener * SetListener(
  Listener *listener
)

Set the listener for events from the Firebase Cloud Messaging servers.

A listener must be set for the application to receive messages from the Firebase Cloud Messaging servers. The implementation may call functions on the Listener provided at any time.

Details
Parameters
listener
A Listener object that listens for events from the Firebase Cloud Messaging servers.
Returns
Pointer to the previously set listener.

Subscribe

void Subscribe(
  const char *topic
)

Subscribe to receive all messages to the specified topic.

Subscribes an app instance to a topic, enabling it to receive messages sent to that topic.

Call this function from the main thread. FCM is not thread safe.

Details
Parameters
topic
The topic to subscribe to. Should be of the form "/topics/\".

Terminate

void Terminate()

Terminate Firebase Cloud Messaging.

Frees resources associated with Firebase Cloud Messaging.

Note:On Android, the services will not be shut down by this method.

Unsubscribe

void Unsubscribe(
  const char *topic
)

Unsubscribe from a topic.

Unsubscribes an app instance from a topic, stopping it from receiving any further messages sent to that topic.

Call this function from the main thread. FCM is not thread safe.

Details
Parameters
topic
The topic to unsubscribe from.

Send feedback about...

Need help? Visit our support page.