public class

FirebaseMessaging

extends Object
java.lang.Object
   ↳ com.google.firebase.messaging.FirebaseMessaging

Class Overview

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());

Summary

Constants
String INSTANCE_ID_SCOPE Specifies scope used in obtaining a registration token when calling getToken()
Public Methods
static FirebaseMessaging getInstance()
void send(RemoteMessage message)
void subscribeToTopic(String topic)
Subscribe to topic in background.
void unsubscribeFromTopic(String topic)
Unsubscribe from topic in background.
[Expand]
Inherited Methods
From class java.lang.Object

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 FirebaseMessaging getInstance ()

public void send (RemoteMessage message)

Parameters
message RemoteMessage

public void subscribeToTopic (String topic)

Subscribe to topic in background.

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