Push notifications enable you to deliver personalized content to your users. You can use deep links to direct users to specific pages in your app, and measure reattributions.
- The push token is a unique identifier that can be used to sort Audiences and client callbacks.
- Push tokens are also required for uninstall and reinstall measurement.
How it works
Each device generates a unique push token that's used to target it. The push token is sent to Adjust when the following information is passed to the MobileCore.trackAction
API:
AdjustAdobeExtension.ADOBE_ADJUST_ACTION_SET_PUSH_TOKEN
: a string constant that maps to thesetPushToken
method.contextData
: a HashMap of values used to configure your push token.
When you call MobileCore.trackAction
with these arguments, the Adjust extension the token to the setPushToken
method and sends the information to Adjust.
Reference
The contextData
HashMap holds information about an action. To configure your push token, add the following key-value pair to your HashMap.
AdjustAdobeExtension.ADOBE_ADJUST_PUSH_TOKEN
The device's push token.
Example: Send a push token
To send a push token to Adjust, you need to add a function to your main activity. In this tutorial, you'll build on MainActivity.java
from the integration guide and add a new function called sendPushTokenToAdjust
which will send an updated push token to Adjust. The final result looks like this:
Here's what you need to do:
First, import the following classes:
com.adobe.marketing.mobile.MobileCore
: this class is used to send information to Adobe and Adjust.java.util.HashMap
: this class is used to generate thecontextData
HashMap.java.util.Map
: this class is used to type thecontextData
HashMap.
Next, create a new function inside the
MainActivity
class calledsendPushTokenToAdjust
. This function takes aView
as an argument and returnsvoid.
Inside the
sendPushTokenToAdjust
function, declare a newString
variable calledaction
and assign it the valueAdjustAdobeExtension.ADOBE_ADJUST_ACTION_SET_PUSH_TOKEN
. This is used to tellMobileCore.trackAction
which action to handle.Create a new HashMap variable called
contextData
. This is used to hold the properties of the action.Add your push token to the HashMap using the
AdjustAdobeExtension.ADOBE_ADJUST_PUSH_TOKEN
key. This example sets the push token to"de18dbf8-f38a-4962-8f1e-44abcf43055d"
.Finally, call
MobileCore.trackAction
with youraction
andcontextData
variables to send the push token to Adjust.
That's it! When the user performs an action that maps to the sendPushTokenToAdjust
function, your push token is sent to Adjust.