Getting Ready for App Tracking Transparency in iOS 14.5
Written on
Chapter 1: Understanding App Tracking Transparency
In June 2020, during WWDC20, Apple introduced a significant change: starting with iOS 14, app developers are required to obtain user permission before tracking their activity. This means that applications can no longer access the device's IDFA (Identifier for Advertisers) without explicit consent from users.
Initially, in September 2020, Apple postponed the enforcement of this rule to allow developers additional time to adapt. However, as of April 2021, Apple urged developers to prepare for App Tracking Transparency, signaling that full enforcement would be implemented with the public release of iOS 14.5.
As developers, our goal is to ensure our applications function seamlessly when this update goes live. If your app utilizes IDFA and you want to ensure compliance with App Tracking Transparency, continue reading.
Understanding IDFA
Before we delve into the technical aspects, it's important to clarify what IDFA is. It's crucial not to confuse IDFA with IDFV (Identifier for Vendor); only IDFA requires user authorization.
IDFA is a unique alphanumeric string assigned to each device and is primarily used for advertising purposes like targeting, frequency capping, detecting ad fraud, and measuring campaign effectiveness. For instance, an IDFA might appear as follows: CE3BB49C-0F44-4DB9-9F6D-B2025A8A4FF7.
Here are some key characteristics of IDFA:
- Each device has a distinct IDFA.
- It serves as a device-level identifier, meaning that applications from different vendors on the same device share the same IDFA.
- Deleting an app does not reset or alter the IDFA since it is tied to the device.
- Disabling and re-enabling app tracking will reset the IDFA.
Pro Tip:
To disable app tracking in iOS 14, navigate to Settings > Privacy > Tracking > toggle off “Allow Apps to Request to Track” and opt for “Ask Apps to Stop Tracking”.
Requesting Permission to Track
Prior to iOS 14.5, developers could easily access IDFA without restrictions using the following code:
let idfa = ASIdentifierManager.shared().advertisingIdentifier
However, in iOS 14.5, if you attempt to access IDFA without user permission, it will return a zeroed-out IDFA:
00000000-0000-0000-0000-000000000000
To request permission, you must add the NSUserTrackingUsageDescription key to your info.plist. This key should contain a descriptive string that informs users why your app seeks permission to track their activity.
Once this is set up, you can utilize the AppTrackingTransparency framework to prompt users for permission:
ATTrackingManager.requestTrackingAuthorization { status in
// Handle the response
}
Key Points to Note:
- The requestTrackingAuthorization(completionHandler:) function only displays the permission alert if the tracking status is .notDetermined. If the status has already been set, it will trigger the completion handler without showing the alert.
- The alert will not appear if “Allow Apps to Request to Track” is disabled in the system privacy settings.
- The completion handler runs on a background thread, so if you need to update the UI, ensure you dispatch it to the main thread.
Note: As of this writing, there is a bug in the iOS simulator that causes IDFA to always return zero. Testing on a real device is recommended to avoid unexpected behavior.
Handling Access Denied
Now that you know how to request tracking permission, what happens if a user denies access to IDFA? One effective approach is to provide a shortcut to the settings so users can modify their tracking preferences easily:
if let url = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
Alternatively, consider not using IDFA at all, which may be feasible if you're only using it for campaign measurement. Apple offers a class for validating advertisement-driven app installations called SKAdNetwork. This API allows advertisers to measure the success of their campaigns while preserving user privacy.
Wrapping Up
Apple continues to enhance privacy controls across its ecosystem. This shift demonstrates Apple's commitment to user privacy. As developers, it is our responsibility to ensure our applications comply with Apple's privacy policies, fostering a sense of security for our users.
If you found this article helpful, feel free to explore my other iOS development resources or connect with me on Twitter. Thank you for reading!
Chapter 2: Video Resources
To further understand App Tracking Transparency and its implications, check out the following videos:
The first video titled "Stop Apps From Tracking You! Apple iOS 14.5 App Tracking Transparency Explained" delves into the features and functions of this new policy.
The second video "App Tracking Transparency Explained — iOS 14.5 is Out!" provides an overview of what developers need to know about this update.