YandexMetricaPush class

com.yandex.metrica.push

public final class YandexMetricaPush

Methods of the class are used for configuring the Push SDK library.

Methods

void init(@NonNull final Context ctx)

Initializes the library in the app. Method should be invoked after initialization AppMetrica SDK.

String getToken()

Returns the push token.

NotificationChannel getDefaultNotificationChannel()

Returns the push notification channel NotificationChannel, which is used by default. You can set settings for it using the methods NotificationChannel until the first push notification is received.

void init(@NonNull final Context ctx)

Initializes the library in the app. Method should be invoked after initialization AppMetrica SDK.

String getToken()

Returns the push token.

NotificationChannel getDefaultNotificationChannel()

Returns the push notification channel NotificationChannel, which is used by default. You can set settings for it using the methods NotificationChannel until the first push notification is received.

Fields

String OPEN_DEFAULT_ACTIVITY_ACTION

Intent action for execute the Activity by default. It can be used to detect the app start via AppMetrica push notification.

String EXTRA_PAYLOAD
An arbitrary data string that is passed in the push notification:
  • In the Additional data field when sending from the AppMetrica interface.
  • In the data field when sending using the Push API.
String OPEN_DEFAULT_ACTIVITY_ACTION

Intent action for execute the Activity by default. It can be used to detect the app start via AppMetrica push notification.

String EXTRA_PAYLOAD
An arbitrary data string that is passed in the push notification:
  • In the Additional data field when sending from the AppMetrica interface.
  • In the data field when sending using the Push API.

Method descriptions

init

public static synchronized void init(@NonNull final Context ctx)

Initializes the library in the app. Method should be invoked after initialization AppMetrica SDK.

Parameters:
ctx

The instance of the Context class.

ctx

The instance of the Context class.

getToken

public static synchronized String getToken()

Returns the push token.

Returns:

The push token or null, if the token is not available yet.

getDefaultNotificationChannel

public static synchronized NotificationChannel getDefaultNotificationChannel()

Returns the push notification channel NotificationChannel, which is used by default. You can set settings for it using the methods NotificationChannel until the first push notification is received.

Returns:

The instance of NotificationChannel, which is used by default.

Field descriptions

OPEN_DEFAULT_ACTIVITY_ACTION

public final String OPEN_DEFAULT_ACTIVITY_ACTION = "com.yandex.metrica.push.action.OPEN"

Intent action for execute the Activity by default. It can be used to detect the app start via AppMetrica push notification.

public class LaunchActivity extends Activity {   @Override   protected void onCreate(Bundle savedInstanceState) {       super.onCreate(saveInstanceState);       Intent intent = getIntent();       String action = intent.getAction();       if (YandexMetricaPush.OPEN_DEFAULT_ACTIVITY_ACTION.equals(action)) {           // Handle the app start via AppMetrica push notification.           ...
       }   }}
Copied to clipboard

EXTRA_PAYLOAD

public final String EXTRA_PAYLOAD = ".extra.payload"

An arbitrary data string that is passed in the push notification:
  • In the Additional data field when sending from the AppMetrica interface.
  • In the data field when sending using the Push API.