public class

FirebaseMessagingService

extends Service
java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ com.google.firebase.messaging.FirebaseMessagingService

Class Overview

Base class for communicating with Firebase Messaging.

It also provides functionality such as automatically displaying notifications.

Override base class methods to handle any events required by the application. Methods are invoked on a background thread.

Include the following in the manifest:

 <service android:name=".YourFirebaseMessagingService">
     <intent-filter>
         <action android:name="com.google.firebase.MESSAGING_EVENT" />
     </intent-filter>
 </service>

Summary

[Expand]
Inherited Constants
From class android.app.Service
From class android.content.Context
From interface android.content.ComponentCallbacks2
Public Constructors
FirebaseMessagingService()
Public Methods
void onDeletedMessages()
Called when the FCM server deletes pending messages.
void onMessageReceived(RemoteMessage message)
Called when a message is received.
void onMessageSent(String msgId)
Called when an upstream message has been successfully sent to the GCM connection server.
void onSendError(String msgId, Exception exception)
Called when there was an error sending an upstream message.
[Expand]
Inherited Methods
From class android.app.Service
From class android.content.ContextWrapper
From class android.content.Context
From class java.lang.Object
From interface android.content.ComponentCallbacks2
From interface android.content.ComponentCallbacks

Public Constructors

public FirebaseMessagingService ()

Public Methods

public void onDeletedMessages ()

Called when the FCM server deletes pending messages. This may be due to:

  1. Too many messages stored on the FCM server. This can occur when an app's servers send a bunch of non-collapsible messages to FCM servers while the device is offline.
  2. The device hasn't connected in a long time and the app server has recently (within the last 4 weeks) sent a message to the app on that device.

It is recommended that the app do a full sync with the app server after receiving this call. For more info see: https://firebase.google.com/docs/cloud-messaging/android/receive#override-ondeletedmessages

public void onMessageReceived (RemoteMessage message)

Called when a message is received. This is also called when a notification message is received while the app is in the foreground. The notification parameters can be retrieved with getNotification().

Parameters
message RemoteMessage: Remote message that has been received.

public void onMessageSent (String msgId)

Called when an upstream message has been successfully sent to the GCM connection server.

Parameters
msgId String: of the upstream message sent using send(RemoteMessage).

public void onSendError (String msgId, Exception exception)

Called when there was an error sending an upstream message.

Parameters
msgId String: of the upstream message sent using send(RemoteMessage).
exception Exception: description of the error, typically a SendException.