| java.lang.Object | |
| ↳ | com.google.firebase.messaging.FirebaseMessaging |
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 Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 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)
This method is deprecated.
Use
sendEach(List) instead.
| ||||||||||
| BatchResponse |
sendAll(List<Message> messages, boolean dryRun)
This method is deprecated.
Use
sendEach(List, boolean) instead.
| ||||||||||
| ApiFuture<BatchResponse> |
sendAllAsync(List<Message> messages)
This method is deprecated.
Use
sendEachAsync(List) instead.
| ||||||||||
| ApiFuture<BatchResponse> |
sendAllAsync(List<Message> messages, boolean dryRun)
This method is deprecated.
Use
sendEachAsync(List, boolean) instead.
| ||||||||||
| 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 |
sendEach(List<Message> messages)
Sends each message in the given list via Firebase Cloud Messaging.
| ||||||||||
| BatchResponse |
sendEach(List<Message> messages, boolean dryRun)
Sends each message in the given list via Firebase Cloud Messaging.
| ||||||||||
| ApiFuture<BatchResponse> |
sendEachAsync(List<Message> messages)
Similar to
sendEach(List) but performs the operation asynchronously. | ||||||||||
| ApiFuture<BatchResponse> |
sendEachAsync(List<Message> messages, boolean dryRun)
Similar to
sendEach(List, boolean) but performs the operation asynchronously. | ||||||||||
| BatchResponse |
sendEachForMulticast(MulticastMessage message)
Sends the given multicast message to all the FCM registration tokens specified in it.
| ||||||||||
| BatchResponse |
sendEachForMulticast(MulticastMessage message, boolean dryRun)
Sends the given multicast message to all the FCM registration tokens specified in it.
| ||||||||||
| ApiFuture<BatchResponse> |
sendEachForMulticastAsync(MulticastMessage message)
Similar to
sendEachForMulticast(MulticastMessage) but performs the operation
asynchronously. | ||||||||||
| ApiFuture<BatchResponse> |
sendEachForMulticastAsync(MulticastMessage message, boolean dryRun)
Similar to
sendEachForMulticast(MulticastMessage, boolean) but performs the operation
asynchronously. | ||||||||||
| BatchResponse |
sendMulticast(MulticastMessage message, boolean dryRun)
This method is deprecated.
Use
sendEachForMulticast(MulticastMessage, boolean) instead.
| ||||||||||
| BatchResponse |
sendMulticast(MulticastMessage message)
This method is deprecated.
Use
sendEachForMulticast(MulticastMessage) instead.
| ||||||||||
| ApiFuture<BatchResponse> |
sendMulticastAsync(MulticastMessage message)
This method is deprecated.
Use
sendEachForMulticastAsync(MulticastMessage) instead.
| ||||||||||
| ApiFuture<BatchResponse> |
sendMulticastAsync(MulticastMessage message, boolean dryRun)
This method is deprecated.
Use
sendEachForMulticastAsync(MulticastMessage, boolean) instead.
| ||||||||||
| 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. | ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Gets the FirebaseMessaging instance for the default FirebaseApp.
FirebaseMessaging instance for the default FirebaseApp.
Gets the FirebaseMessaging instance for the specified FirebaseApp.
FirebaseMessaging instance for the specified FirebaseApp.
Sends the given Message via Firebase Cloud Messaging.
| message | A non-null Message to be sent. |
|---|
| FirebaseMessagingException | If an error occurs while handing the message off to FCM for delivery. |
|---|
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 operation. The dryRun
option is useful for determining whether an FCM registration has been deleted. However, it
cannot be used to validate APNs tokens.
| message | A non-null Message to be sent. |
|---|---|
| dryRun | a boolean indicating whether to perform a dry run (validation only) of the send. |
| FirebaseMessagingException | If an error occurs while handing the message off to FCM for delivery. |
|---|
This method is deprecated.
Use sendEach(List) instead.
Sends all the messages in the given list via Firebase Cloud Messaging. Employs batching to
send the entire list as a single RPC call. Compared to the send(Message) method, this
is a significantly more efficient way to send multiple messages.
The responses list obtained by calling getResponses() on the return
value corresponds to the order of input messages.
| messages | A non-null, non-empty list containing up to 500 messages. |
|---|
BatchResponse indicating the result of the operation.| FirebaseMessagingException | If an error occurs while handing the messages off to FCM for
delivery. An exception here indicates a total failure, meaning that none of the messages in
the list could be sent. Partial failures are indicated by a BatchResponse return
value. |
|---|
This method is deprecated.
Use sendEach(List, boolean) instead.
Sends all the messages in the given list via Firebase Cloud Messaging. Employs batching to
send the entire list as a single RPC call. Compared to the send(Message) method, this
is a significantly more efficient way to send multiple messages.
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 operation. The dryRun
option is useful for determining whether an FCM registration has been deleted. But it cannot be
used to validate APNs tokens.
The responses list obtained by calling getResponses() on the return
value corresponds to the order of input messages.
| messages | A non-null, non-empty list containing up to 500 messages. |
|---|---|
| dryRun | A boolean indicating whether to perform a dry run (validation only) of the send. |
BatchResponse indicating the result of the operation.| FirebaseMessagingException | If an error occurs while handing the messages off to FCM for
delivery. An exception here indicates a total failure, meaning that none of the messages in
the list could be sent. Partial failures are indicated by a BatchResponse return
value. |
|---|
This method is deprecated.
Use sendEachAsync(List) instead.
Similar to sendAll(List) but performs the operation asynchronously.
| messages | A non-null, non-empty list containing up to 500 messages. |
|---|
ApiFuture that will complete with a BatchResponse when
the messages have been sent.
This method is deprecated.
Use sendEachAsync(List, boolean) instead.
Similar to sendAll(List, boolean) but performs the operation asynchronously.
| messages | A non-null, non-empty list containing up to 500 messages. |
|---|---|
| dryRun | A boolean indicating whether to perform a dry run (validation only) of the send. |
ApiFuture that will complete with a BatchResponse when
the messages have been sent, or when the emulation has finished.Similar to send(Message, boolean) but performs the operation asynchronously.
| message | A non-null Message to be sent. |
|---|---|
| dryRun | a boolean indicating whether to perform a dry run (validation only) of the send. |
ApiFuture that will complete with a message ID string when the message
has been sent, or when the emulation has finished.
Similar to send(Message) but performs the operation asynchronously.
| message | A non-null Message to be sent. |
|---|
ApiFuture that will complete with a message ID string when the message
has been sent.
Sends each message in the given list via Firebase Cloud Messaging.
Unlike sendAll(List), this method makes an HTTP call for each message in the
given array.
The list of responses obtained by calling getResponses() on the return
value is in the same order as the input list.
| messages | A non-null, non-empty list containing up to 500 messages. |
|---|
BatchResponse indicating the result of the operation.| FirebaseMessagingException | If an error occurs while handing the messages off to FCM for
delivery. An exception here or a BatchResponse with all failures indicates a total
failure, meaning that none of the messages in the list could be sent. Partial failures or
no failures are only indicated by a BatchResponse.
|
|---|
Sends each message in the given list via Firebase Cloud Messaging.
Unlike sendAll(List), this method makes an HTTP call for each message in the
given array.
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 operation. The dryRun
option is useful for determining whether an FCM registration has been deleted. But it cannot be
used to validate APNs tokens.
The list of responses obtained by calling getResponses() on the return
value is in the same order as the input list.
| messages | A non-null, non-empty list containing up to 500 messages. |
|---|---|
| dryRun | A boolean indicating whether to perform a dry run (validation only) of the send. |
BatchResponse indicating the result of the operation.| FirebaseMessagingException | If an error occurs while handing the messages off to FCM for
delivery. An exception here or a BatchResponse with all failures indicates a total
failure, meaning that none of the messages in the list could be sent. Partial failures or
no failures are only indicated by a BatchResponse.
|
|---|
Similar to sendEach(List) but performs the operation asynchronously.
| messages | A non-null, non-empty list containing up to 500 messages. |
|---|
ApiFuture that will complete with a BatchResponse when
the messages have been sent.
Similar to sendEach(List, boolean) but performs the operation asynchronously.
| messages | A non-null, non-empty list containing up to 500 messages. |
|---|---|
| dryRun | A boolean indicating whether to perform a dry run (validation only) of the send. |
ApiFuture that will complete with a BatchResponse when
the messages have been sent.
Sends the given multicast message to all the FCM registration tokens specified in it.
This method uses the sendEach(List) API under the hood to send the given
message to all the target recipients. The list of responses obtained by calling
getResponses() on the return value is in the same order as the
tokens in the MulticastMessage.
| message | A non-null MulticastMessage |
|---|
BatchResponse indicating the result of the operation.| FirebaseMessagingException | If an error occurs while handing the messages off to FCM for
delivery. An exception here or a BatchResponse with all failures indicates a total
failure, meaning that none of the messages in the list could be sent. Partial failures or
no failures are only indicated by a BatchResponse.
|
|---|
Sends the given multicast message to all the FCM registration tokens specified in it.
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 operation. The dryRun
option is useful for determining whether an FCM registration has been deleted. But it cannot be
used to validate APNs tokens.
This method uses the sendEach(List) API under the hood to send the given
message to all the target recipients. The list of responses obtained by calling
getResponses() on the return value is in the same order as the
tokens in the MulticastMessage.
| message | A non-null MulticastMessage. |
|---|---|
| dryRun | A boolean indicating whether to perform a dry run (validation only) of the send. |
BatchResponse indicating the result of the operation.| FirebaseMessagingException | If an error occurs while handing the messages off to FCM for
delivery. An exception here or a BatchResponse with all failures indicates a total
failure, meaning that none of the messages in the list could be sent. Partial failures or
no failures are only indicated by a BatchResponse.
|
|---|
Similar to sendEachForMulticast(MulticastMessage) but performs the operation
asynchronously.
| message | A non-null MulticastMessage. |
|---|
ApiFuture that will complete with a BatchResponse when
the messages have been sent.
Similar to sendEachForMulticast(MulticastMessage, boolean) but performs the operation
asynchronously.
| message | A non-null MulticastMessage. |
|---|---|
| dryRun | A boolean indicating whether to perform a dry run (validation only) of the send. |
ApiFuture that will complete with a BatchResponse when
the messages have been sent.
This method is deprecated.
Use sendEachForMulticast(MulticastMessage, boolean) instead.
Sends the given multicast message to all the FCM registration tokens specified in it.
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 operation. The dryRun
option is useful for determining whether an FCM registration has been deleted. But it cannot be
used to validate APNs tokens.
This method uses the sendAll(List) API under the hood to send the given
message to all the target recipients. The responses list obtained by calling
getResponses() on the return value corresponds to the order of tokens
in the MulticastMessage.
| message | A non-null MulticastMessage. |
|---|---|
| dryRun | A boolean indicating whether to perform a dry run (validation only) of the send. |
BatchResponse indicating the result of the operation.| FirebaseMessagingException | If an error occurs while handing the messages off to FCM for
delivery. An exception here indicates a total failure, meaning that the messages could not
be delivered to any recipient. Partial failures are indicated by a BatchResponse
return value. |
|---|
This method is deprecated.
Use sendEachForMulticast(MulticastMessage) instead.
Sends the given multicast message to all the FCM registration tokens specified in it.
This method uses the sendAll(List) API under the hood to send the given
message to all the target recipients. The responses list obtained by calling
getResponses() on the return value corresponds to the order of tokens
in the MulticastMessage.
| message | A non-null MulticastMessage |
|---|
BatchResponse indicating the result of the operation.| FirebaseMessagingException | If an error occurs while handing the messages off to FCM for
delivery. An exception here indicates a total failure, meaning that the messages could not
be delivered to any recipient. Partial failures are indicated by a BatchResponse
return value. |
|---|
This method is deprecated.
Use sendEachForMulticastAsync(MulticastMessage) instead.
Similar to sendMulticast(MulticastMessage) but performs the operation
asynchronously.
| message | A non-null MulticastMessage. |
|---|
ApiFuture that will complete with a BatchResponse when
the messages have been sent.
This method is deprecated.
Use sendEachForMulticastAsync(MulticastMessage, boolean) instead.
Similar to sendMulticast(MulticastMessage, boolean) but performs the operation
asynchronously.
| message | A non-null MulticastMessage. |
|---|---|
| dryRun | A boolean indicating whether to perform a dry run (validation only) of the send. |
ApiFuture that will complete with a BatchResponse when
the messages have been sent.Subscribes a list of registration tokens to a topic.
| registrationTokens | A non-null, non-empty list of device registration tokens, with at most 1000 entries. |
|---|---|
| topic | Name of the topic to subscribe to. May contain the /topics/ prefix. |
| FirebaseMessagingException |
|---|
Similar to subscribeToTopic(List, String) but performs the operation asynchronously.
| registrationTokens | A non-null, non-empty list of device registration tokens, with at most 1000 entries. |
|---|---|
| topic | Name of the topic to subscribe to. May contain the /topics/ prefix. |
ApiFuture that will complete with a TopicManagementResponse.
Unsubscribes a list of registration tokens from a topic.
| registrationTokens | A non-null, non-empty list of device registration tokens, with at most 1000 entries. |
|---|---|
| topic | Name of the topic to unsubscribe from. May contain the /topics/ prefix. |
| FirebaseMessagingException |
|---|
Similar to unsubscribeFromTopic(List, String) but performs the operation
asynchronously.
| registrationTokens | A non-null, non-empty list of device registration tokens, with at most 1000 entries. |
|---|---|
| topic | Name of the topic to unsubscribe from. May contain the /topics/ prefix. |
ApiFuture that will complete with a TopicManagementResponse.