Summary: Constants | Methods | Inherited Methods | [Expand All]
public class

# FirebaseMessaging

extends Object

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

## Class Overview

Firebase Cloud Messaging enables apps to communicate with their app servers using simple messages.

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
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()

## 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)

#### 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}".