FirebaseMessaging

public class FirebaseMessaging extends Object

Firebase Cloud Messaging lets you reliably deliver messages at no cost.

Messages can be sent from the Firebase Notifications console, using a topic that has been subscribed to via subscribeToTopic(String), or by getting a token for an app instance via getToken().

In order to receive Firebase messages, declare an implementation of FirebaseMessagingService in the app manifest. To process messages, override base class methods to handle any events required by the application.

Client apps can send upstream messages back to the app server using the XMPP-based Cloud Connection Server. For example:

 FirebaseMessaging.getInstance().send(
     new RemoteMessage.Builder(SENDER_ID + "@gcm.googleapis.com")
     .setMessageId(id)
     .addData("key", "value")
     .build());

Constant Summary

String INSTANCE_ID_SCOPE Specifies scope used in obtaining a registration token when calling getToken()

Public Method Summary

synchronized static FirebaseMessaging
void
send(RemoteMessage message)
void
subscribeToTopic(String topic)
Subscribe to topic in background.
void
unsubscribeFromTopic(String topic)
Unsubscribe from topic in background.

Inherited Method Summary

Constants

public static final String INSTANCE_ID_SCOPE

Specifies scope used in obtaining a registration token when calling getToken()

Constant Value: "FCM"

Public Methods

public static synchronized FirebaseMessaging getInstance ()

public void send (RemoteMessage message)

public void subscribeToTopic (String topic)

Subscribe to topic in background.

Parameters
topic The name of the topic to subscribe. Must match the following regular expression: "[a-zA-Z0-9-_.~%]{1,900}".

public void unsubscribeFromTopic (String topic)

Unsubscribe from topic in background.

Parameters
topic The name of the topic to unsubscribe from. Must match the following regular expression: "[a-zA-Z0-9-_.~%]{1,900}".

Send feedback about...

Need help? Visit our support page.