Go to console

FirebaseMessaging

public class FirebaseMessaging extends Object

This class is the entry point for all server-side Firebase Cloud Messaging actions.

You can get an instance of FirebaseMessaging via getInstance(FirebaseApp), and then use it to send messages or manage FCM topic subscriptions.

Public Method Summary

static FirebaseMessaging
getInstance()
Gets the FirebaseMessaging instance for the default FirebaseApp.
synchronized static FirebaseMessaging
getInstance(FirebaseApp app)
Gets the FirebaseMessaging instance for the specified FirebaseApp.
String
send(Message message)
Sends the given Message via Firebase Cloud Messaging.
String
send(Message message, boolean dryRun)
Sends the given Message via Firebase Cloud Messaging.
BatchResponse
sendAll(List<Message> messages)
Sends all the messages in the given list via Firebase Cloud Messaging.
BatchResponse
sendAll(List<Message> messages, boolean dryRun)
Sends all the messages in the given list via Firebase Cloud Messaging.
ApiFuture<BatchResponse>
sendAllAsync(List<Message> messages)
Similar to sendAll(List) but performs the operation asynchronously.
ApiFuture<BatchResponse>
sendAllAsync(List<Message> messages, boolean dryRun)
Similar to sendAll(List, boolean) but performs the operation asynchronously.
ApiFuture<String>
sendAsync(Message message, boolean dryRun)
Similar to send(Message, boolean) but performs the operation asynchronously.
ApiFuture<String>
sendAsync(Message message)
Similar to send(Message) but performs the operation asynchronously.
BatchResponse
sendMulticast(MulticastMessage message)
Sends the given multicast message to all the FCM registration tokens specified in it.
BatchResponse
sendMulticast(MulticastMessage message, boolean dryRun)
Sends the given multicast message to all the FCM registration tokens specified in it.
ApiFuture<BatchResponse>
sendMulticastAsync(MulticastMessage message)
Similar to sendMulticast(MulticastMessage) but performs the operation asynchronously.
ApiFuture<BatchResponse>
sendMulticastAsync(MulticastMessage message, boolean dryRun)
Similar to sendMulticast(MulticastMessage, boolean) but performs the operation asynchronously.
TopicManagementResponse
subscribeToTopic(List<String> registrationTokens, String topic)
Subscribes a list of registration tokens to a topic.
ApiFuture<TopicManagementResponse>
subscribeToTopicAsync(List<String> registrationTokens, String topic)
Similar to subscribeToTopic(List, String) but performs the operation asynchronously.
TopicManagementResponse
unsubscribeFromTopic(List<String> registrationTokens, String topic)
Unsubscribes a list of registration tokens from a topic.
ApiFuture<TopicManagementResponse>
unsubscribeFromTopicAsync(List<String> registrationTokens, String topic)
Similar to unsubscribeFromTopic(List, String) but performs the operation asynchronously.

Inherited Method Summary

Public Methods

public static FirebaseMessaging getInstance ()

Gets the FirebaseMessaging instance for the default FirebaseApp.

Returns

public static synchronized FirebaseMessaging getInstance (FirebaseApp app)

Gets the FirebaseMessaging instance for the specified FirebaseApp.

Returns

public String send (Message message)

Sends the given Message via Firebase Cloud Messaging.

Parameters
message A non-null Message to be sent.
Returns
  • A message ID string.
Throws
FirebaseMessagingException If an error occurs while handing the message off to FCM for delivery.

public String send (Message message, boolean dryRun)

Sends the given Message via Firebase Cloud Messaging.

If the dryRun option is set to true, the message will not be actually sent. Instead FCM performs all the necessary validations, and emulates the send operat