adjust-icon

Set up App Tracking Transparency

If you want to record the device’s ID for Advertisers (IDFA), you must display a prompt to get your user’s authorization. To do this, you need to include Apple’s App Tracking Transparency (ATT) framework in your app. The Adjust SDK stores the user’s authorization status and sends it to Adjust’s servers with each request.

Authorization statuses

StatusCodeDescription
ATTrackingManagerAuthorizationStatusNotDetermined0The user hasn’t responded to the access prompt yet
ATTrackingManagerAuthorizationStatusRestricted1Access to app-related data is blocked at the device level
ATTrackingManagerAuthorizationStatusDenied2The user has denied access to app-related data for device tracking
ATTrackingManagerAuthorizationStatusAuthorized3The user has approved access to app-related data for device tracking

App-tracking authorization wrapper

Method signature
static void requestTrackingAuthorizationWithCompletionHandler(void (*trackingStatusCallback)(int status));

The Adjust SDK contains a wrapper around Apple’s requestTrackingAuthorizationWithCompletionHandler method. You can use this wrapper if you don’t want to customize the ATT prompt.

The callback method triggers when your user responds to the consent dialog. This method sends the user’s consent status code to Adjust’s servers. You can define responses to each status code within the callback function.

You must specify text content for the tracking request dialog. To do this, add your text to the NSUserTrackingUsageDescription key in your Info.plist file.

static void authorizationStatusCallback(int status) {
switch (status) {
case 0:
// ATTrackingManagerAuthorizationStatusNotDetermined case
break;
case 1:
// ATTrackingManagerAuthorizationStatusRestricted case
break;
case 2:
// ATTrackingManagerAuthorizationStatusDenied case
break;
case 3:
// ATTrackingManagerAuthorizationStatusAuthorized case
break;
}
}
// ...
Adjust2dx::requestTrackingAuthorizationWithCompletionHandler(authorizationStatusCallback);

Example

This example shows how to log a human-readable description of the user’s authorization status when they interact with a prompt.

static void authorizationStatusCallback(int status) {
switch (status) {
case 0:
CCLOG("The user hasn't responded to the access prompt yet.");
break;
case 1:
CCLOG(("Access to app-related data is blocked at the device level.");)
break;
case 2:
CCLOG("The user has denied access to app-related data for device tracking.");
break;
case 3:
CCLOG("The user has approved access to app-related data for device tracking.");
break;
}
}
Adjust2dx::requestTrackingAuthorizationWithCompletionHandler(authorizationStatusCallback);

Get current authorization status

Method signature
static int getAppTrackingAuthorizationStatus();

You can retrieve a user’s current authorization status at any time. Call the getAppTrackingAuthorizationStatus method to return the authorization status code as an integer.

Adjust2dx::getAppTrackingAuthorizationStatus();

Example

This example shows how to collect the user’s authorization status and convert it to a String. This information is assigned to a variable called authorizationStatus and passed as a session partner parameter with the key "status".

std::string authorizationStatus = Adjust2dx::getAppTrackingAuthorizationStatus().c_str();
Adjust2dx::addSessionPartnerParameter("status", authorizationStatus);

Check for authorization status changes

Method signature
static void checkForNewAttStatus();

If you use a custom ATT prompt, you need to inform the Adjust SDK of changes to the user’s authorization status. Call the checkForNewAttStatus method to send the authorization status to Adjust’s servers.

Adjust2dx::checkForNewAttStatus();