Skip to main content

Push token

Push tokens are used for Audience Builder and client callbacks. They are also required for uninstall and reinstall tracking.

After your app registers for remote notifications and receives the APNs device token (and whenever that token changes), pass it to Adtrace with setDeviceToken:.

Call this method on Adtrace after the SDK has started, typically from application:didRegisterForRemoteNotificationsWithDeviceToken: in your app delegate.

Method signature

+ (void)setDeviceToken:(nonnull NSData *)deviceToken;
ParameterTypeDescription
deviceTokenNSDataThe APNs device token from didRegisterForRemoteNotificationsWithDeviceToken. Pass the NSData value directly. Do not convert it to a string for the native SDK.

Set the push token (native SDK)

Register for remote notifications, then forward the token to Adtrace when iOS delivers it.

AppDelegate.m
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[Adtrace setDeviceToken:deviceToken];
}

Make sure your app requests notification permission and calls registerForRemoteNotifications before you expect this callback.

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 token string from your native or web push setup.

When to call this

Call setDeviceToken::

  1. When iOS first delivers the device token after registerForRemoteNotifications
  2. Whenever Apple refreshes the token and calls didRegisterForRemoteNotificationsWithDeviceToken again

Send the token after appDidLaunch so the SDK is running when you register it.