MetricaMessagingService class

com.yandex.metrica.push.firebase

public class MetricaMessagingService extends FirebaseMessagingService

Methods of the class are used to configure simultaneous use of the AppMetrica Push SDK and another push service. For more information, see Using with other push services.

Methods

void onMessageReceived(@NonNull final RemoteMessage message)

Called when a push notification is received from Firebase. For more information, see the method description FirebaseMessagingService.onMessageReceived.

void onNewToken(@NonNull String token)

Called when the system generates a new push token. For more information, see the FirebaseMessagingService.onNewToken(String token) method description.

void processPush(@NonNull final Context context, @NonNull final RemoteMessage message)

Sends information about push notification to AppMetrica Push SDK. AppMetrica automatically recognizes own messages and processes only them.

void processPush(@NonNull final Context context, @NonNull final Bundle data)

Sends information about push notification to AppMetrica Push SDK. AppMetrica automatically recognizes own messages and processes only them.

void processToken(@NonNull final Context context, @NonNull final String token)

Sends information about a push token to AppMetrica Push SDK.

boolean isNotificationRelatedToSDK(@NonNull final RemoteMessage notification)

Checks whether the push notification received belongs to the AppMetrica PushSDK.

void onMessageReceived(@NonNull final RemoteMessage message)

Called when a push notification is received from Firebase. For more information, see the method description FirebaseMessagingService.onMessageReceived.

void onNewToken(@NonNull String token)

Called when the system generates a new push token. For more information, see the FirebaseMessagingService.onNewToken(String token) method description.

void processPush(@NonNull final Context context, @NonNull final RemoteMessage message)

Sends information about push notification to AppMetrica Push SDK. AppMetrica automatically recognizes own messages and processes only them.

void processPush(@NonNull final Context context, @NonNull final Bundle data)

Sends information about push notification to AppMetrica Push SDK. AppMetrica automatically recognizes own messages and processes only them.

void processToken(@NonNull final Context context, @NonNull final String token)

Sends information about a push token to AppMetrica Push SDK.

boolean isNotificationRelatedToSDK(@NonNull final RemoteMessage notification)

Checks whether the push notification received belongs to the AppMetrica PushSDK.

Method descriptions

onMessageReceived

public void onMessageReceived(@NonNull final RemoteMessage message)

Called when a push notification is received from Firebase. For more information, see the method description FirebaseMessagingService.onMessageReceived.

Parameters:
message

The instance of RemoteMessage.

message

The instance of RemoteMessage.

onNewToken

public void onNewToken(@NonNull String token)

Called when the system generates a new push token. For more information, see the FirebaseMessagingService.onNewToken(String token) method description.

Parameters:
token

Token used for sending push notifications.

token

Token used for sending push notifications.

processPush

public void processPush(@NonNull final Context context, @NonNull final RemoteMessage message)

Sends information about push notification to AppMetrica Push SDK. AppMetrica automatically recognizes own messages and processes only them.

This method must be called when you simultaneously use AppMetrica Push SDK and Firebase Cloud Messaging.

Parameters:
context The instance of the Context class.
message

The instance of RemoteMessage.

context The instance of the Context class.
message

The instance of RemoteMessage.

processPush

public void processPush(@NonNull final Context context, @NonNull final Bundle data)

Sends information about push notification to AppMetrica Push SDK. AppMetrica automatically recognizes own messages and processes only them.

This method must be called:
Parameters:
context The instance of the Context class.
message

The instance of the Bundle class. To get it, convert data from RemoteMessage.getData() to Bundle.

context The instance of the Context class.
message

The instance of the Bundle class. To get it, convert data from RemoteMessage.getData() to Bundle.

processToken

public void processToken(@NonNull final Context context, @NonNull final String token)

Sends information about a push token to AppMetrica Push SDK.

This method must be called when you simultaneously use AppMetrica Push SDK and Firebase Cloud Messaging.

Parameters:
context The instance of the Context class.
token

Token used for sending push notifications.

context The instance of the Context class.
token

Token used for sending push notifications.

isNotificationRelatedToSDK

static boolean isNotificationRelatedToSDK(@NonNull final RemoteMessage notification)

Checks whether the push notification received belongs to the AppMetrica PushSDK.

Parameters:
notification The instance of RemoteMessage.
notification The instance of RemoteMessage.