Starting from iOS 14, Apple requires apps to request user permission before accessing the Identifier for Advertisers (IDFA) for tracking. This is done using AppTrackingTransparency (ATT). Below are the steps to implement ATT permission in your iOS app.
Info.plist
Before requesting permission, you must add a privacy description in your Info.plist
file.
📌 Open Info.plist
and add the following key-value pair:
<key>NSUserTrackingUsageDescription</key>
<string>We use tracking to provide personalized content and improve your experience.</string>
This message will be displayed in the ATT system prompt.
To request tracking permission, use the AppTrackingTransparency framework.
📌 Update AppDelegate.swift
or call this in your ViewController:
import UIKit
import AppTrackingTransparency
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
requestTrackingPermission()
return true
}
/// Requests App Tracking Transparency (ATT) permission
func requestTrackingPermission() {
if #available(iOS 14, *) {
ATTrackingManager.requestTrackingAuthorization { status in
switch status {
case .authorized:
print("✅ Tracking Authorized")
case .denied:
print("❌ Tracking Denied")
case .restricted:
print("🔒 Tracking Restricted (e.g., parental controls)")
case .notDetermined:
print("⏳ Tracking Not Determined")
@unknown default:
print("❓ Unknown Tracking Status")
}
}
} else {
print("⚠️ ATT Not Supported (iOS version < 14)")
}
}
}
🚨 ATT does NOT work on the iOS Simulator.
✅ You must test on a real iPhone running iOS 14 or later.
Run the app on a real device using:
xcodebuild -scheme YourApp -destination 'platform=iOS,name=Your Device Name' run
Once you request tracking permission:
Open Settings → Privacy & Security → Tracking.
Check if your app appears in the list.
If your app appears with a toggle, ATT is working correctly! ✅
To ensure that ATT is working properly, open Xcode Console (Cmd + Shift + C) and check the logs:
✅ Tracking Authorized
❌ Tracking Denied
🔒 Tracking Restricted (e.g., parental controls)
⏳ Tracking Not Determined
If the ATT popup does not appear, reset tracking permissions:
Open Settings → Privacy & Security → Tracking.
Toggle "Allow Apps to Request to Track" OFF and ON.
Delete and reinstall the app.
Restart your iPhone.