We constantly publish updates to our documentation, which may not yet be available in your language. For the most current information, use the English version.
The App Tracking Transparency framework is only available on iOS devices with Adjust SDK v4.23.0 or later.
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 the Adjust backend with each request.
Authorization statuses
Status
Code
Description
ATTrackingManagerAuthorizationStatusNotDetermined
0
The user has not responded to the access prompt yet.
ATTrackingManagerAuthorizationStatusRestricted
1
Access to app-related data is blocked at the device level.
ATTrackingManagerAuthorizationStatusDenied
2
The user has denied access to app-related data for device tracking.
ATTrackingManagerAuthorizationStatusAuthorized
3
The user has approved access to app-related data for device tracking.
Note:
You might receive a status code of -1 if the SDK is unable to retrieve the ATT status.
The callback method triggers when your user responds to the consent dialog. This method sends the user's consent status code to the Adjust backend. You can define responses to each status code within the callback function.
Tip:
The Adjust SDK also records the consent status if you use a custom prompt. If you show your prompt before initialization, the SDK sends the status with the install event. If you show it after initialization, the SDK sends the status to the backend as soon as the user updates it.
DartiOS
if (Platform.isIOS) {
Adjust.requestTrackingAuthorizationWithCompletionHandler().then((status) {
switch (status) {
case 0:
// ATTrackingManagerAuthorizationStatusNotDetermined case
break;
case 1:
// ATTrackingManagerAuthorizationStatusRestricted case
break;
case 2:
// ATTrackingManagerAuthorizationStatusDenied case
break;
case 3:
// ATTrackingManagerAuthorizationStatusAuthorized case
break;
}
});
}
Example
In this example, we log a human-readable description of the user's authorization status when they interact with the prompt.
Dart
// main.dart
import 'package:adjust_sdk/adjust.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
initPlatformState() async {
AdjustConfig config =
new AdjustConfig('{YourAppToken}', AdjustEnvironment.sandbox);
config.logLevel = AdjustLogLevel.verbose;
Adjust.requestTrackingAuthorizationWithCompletionHandler().then((status) {
print('[Adjust]: Authorization status update!');
switch (status) {
case 0:
print(
'The user has not responded to the access prompt yet.');
break;
case 1:
print(
'Access to app-related data is blocked at the device level.');
break;
case 2:
print(
'The user has denied access to app-related data for device tracking.');
break;
case 3:
print(
'The user has approved access to app-related data for device tracking.');
break;
}
});
Adjust.start(config);
}
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.
Dart
Adjust.getAppTrackingAuthorizationStatus();
Example
In this example, we collect the user's authorization status and convert it to a String. We store this as a variable called authorizationStatus and pass it as a session partner parameter with the key "status".
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 the Adjust backend.