Skip to main content

Push token

Push tokens are used for uninstall and reinstall tracking. After you obtain your FCM token (and whenever its value changes), pass it to Adtrace with setPushToken.

Call this method on AdTrace after the SDK has started (for example in FirebaseMessagingService.onNewToken or when you fetch the current token).

public static void setPushToken(final String token, final Context context)
ParameterTypeDescription
tokenStringYour FCM push notification token for the device
contextContextThe Android context your app runs in. Prefer getApplicationContext() / applicationContext
Recommended overload

Use AdTrace.setPushToken(token, context). The context argument helps the SDK cover more scenarios so the push token is sent reliably.

Set the push token (native SDK)

AdTrace.setPushToken(pushNotificationsToken, getApplicationContext());

Legacy signature (native SDK)

The SDK still supports the previous overload without context:

public static void setPushToken(final String token)
AdTrace.setPushToken(pushNotificationsToken);

Prefer the context overload for new integrations.

WebBridge / WebView SDK

If you have access to the push token from the WebView, call setPushToken in JavaScript:

AdTrace.setPushToken("{YourPushToken}");

Replace {YourPushToken} with the FCM token string.

When to call this

Call setPushToken:

  1. When you first obtain the FCM token after app install or SDK init
  2. Whenever Firebase refreshes the token (onNewToken)

For a full FirebaseMessagingService example, see Uninstall / Reinstall setup and Implementation examples.