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).
Method signature (recommended)
public static void setPushToken(final String token, final Context context)
| Parameter | Type | Description |
|---|---|---|
token | String | Your FCM push notification token for the device |
context | Context | The Android context your app runs in. Prefer getApplicationContext() / applicationContext |
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)
- Java
- Kotlin
AdTrace.setPushToken(pushNotificationsToken, getApplicationContext());
AdTrace.setPushToken(pushNotificationsToken, applicationContext)
Legacy signature (native SDK)
The SDK still supports the previous overload without context:
public static void setPushToken(final String token)
- Java
- Kotlin
AdTrace.setPushToken(pushNotificationsToken);
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:
- When you first obtain the FCM token after app install or SDK init
- Whenever Firebase refreshes the token (
onNewToken)
For a full FirebaseMessagingService example, see Uninstall / Reinstall setup and Implementation examples.