Apple's App Tracking Transparency (ATT) framework is a cornerstone of user privacy on iOS, fundamentally changing how apps can track user activity. Introduced in iOS 14.5, ATT requires apps to explicitly ask for user permission before they can track users across other apps, websites, or offline properties. "Tracking" in Apple's definition involves linking user or device data collected from your app with data collected from other companies for purposes like targeted advertising or measurement. Before you can access the Identifier for Advertisers (IDFA) or engage in cross-app tracking, your app must present the ATT system prompt. This prompt's message is pre-defined by Apple, but you can provide a custom NSUserTrackingUsageDescription in your Info.plist file to explain why your app needs tracking permission.
Building on ATT, iOS 17 introduced privacy manifests, a new requirement designed to enhance transparency and provide users with a clearer understanding of how their data is handled. A privacy manifest is a PrivacyInfo.xcprivacy file bundled with your app and any third-party SDKs it uses. This file declares two critical things: first, how your app and its SDKs use specific "required reason APIs" (like File System APIs or User Defaults) and the justified reasons for their usage; and second, what types of user data your app (and its SDKs) collect, and whether that data is used for tracking. Apple uses these manifests to ensure developers are transparent about data practices, and they are critical for app review and approval.
For developers, the practical implications are significant. You must decide when to present the ATT authorization request to the user, ideally at a point where they understand the value exchange. If a user denies tracking, you must respect that choice and disable any tracking-related functionality. Furthermore, you are now responsible for ensuring that all third-party SDKs integrated into your app provide their own privacy manifests and adhere to Apple's tracking guidelines. Failure to comply with ATT or provide accurate privacy manifests can lead to app rejection during the review process. Ultimately, these measures are about fostering user trust by giving individuals more control and visibility over their personal data.
Key Takeaways
- App Tracking Transparency (ATT) requires explicit user consent via a system prompt before your app can track users across other apps or websites.
- A
PrivacyInfo.xcprivacyfile (privacy manifest) declares how your app and its SDKs use specific APIs and what user data they collect for tracking. - You must provide a
NSUserTrackingUsageDescriptionin yourInfo.plistto explain your app's reason for requesting tracking permission. - Always request ATT authorization before attempting to access the IDFA or engaging in cross-app tracking activities.
- Ensure all third-party SDKs you integrate provide compliant privacy manifests and respect user tracking preferences to avoid app rejection.
Code Example
import AppTrackingTransparency
import AdSupport
func requestTrackingAuthorization() {
if #available(iOS 14, *) {
// Check current authorization status
let status = ATTrackingManager.trackingAuthorizationStatus
if status == .notDetermined {
// Only request if not yet determined
ATTrackingManager.requestTrackingAuthorization { status in
switch status {
case .authorized:
print("Tracking authorized. IDFA: \(ASIdentifierManager.shared().advertisingIdentifier)")
case .denied, .restricted:
print("Tracking denied or restricted.")
case .notDetermined:
print("Tracking status not determined after request.")
@unknown default:
break
}
}
} else {
print("ATT status already set: \(status)")
}
} else {
print("ATT not applicable on iOS versions prior to 14.")
}
}
// Call this function when appropriate in your app's lifecycle,
// for example, after an initial user education screen, but before
// any tracking functionality attempts to operate.How this code works
This Swift code is designed to implement Apple's App Tracking Transparency (ATT) framework. Its primary job is to politely ask users for permission to track their activity across different apps and websites for advertising purposes. This consent is crucial for apps that intend to use the Identifier for Advertisers (IDFA) to personalize ads, ensuring compliance with Apple's privacy guidelines.
The requestTrackingAuthorization function first ensures the device runs #available(iOS 14, *) or later, as ATT is a newer feature. Inside, it uses ATTrackingManager.trackingAuthorizationStatus to check the current permission state. Crucially, the code only calls ATTrackingManager.requestTrackingAuthorization if the status is .notDetermined. This subtle but important order-of-operations prevents bombarding users with repeated prompts if they've already made a choice, either granting or denying tracking. Once the request is made, the completion handler with the switch status statement processes the user's decision, logging whether tracking was authorized (and revealing the IDFA via ASIdentifierManager.shared().advertisingIdentifier), denied, or restricted. This ensures the app respects the user's privacy choices and adapts its behavior accordingly.