App Tracking Transparency in Swift. How to Implement? How to Retrieve IDFA?

Written by kagangirgin | Published 2025/07/31
Tech Story Tags: swift | gdpr | ios-development | ios-app-development | app-tracking-transparency | how-to-retrieve-idfa | retrieve-idfa

TLDRIf your app accesses to websites or using 3rd party libraries, you have to implement App Tracking Transparency. via the TL;DR App

What is App Tracking Transparency?


Since iOS 14, Apple requires extra information about tracking users’ activity. It is not only about tracking them inside apps but also in cases when an app uses access to websites or using some analytics tools like Firebase or Adjust. It means, if in-app WebKit or 3rd party libraries which logs user activities are implemented, there should be added an extra policy about tracking.


If your app accesses to websites or using 3rd party libraries, you have to implement App Tracking Transparency. In this article, I’ll show you how to do this and how to avoid common mistakes but first we'll learn what's IDFA as well.


What is IDFA?


IDFA (Identifier for Advertisers) is an alphanumeric UUID that is unique to a device. If you try to access without App Tracking Transparency consent you shall be given a zeroed out IDFA. You can see the an original IDFA and Zeroed Out IDFA below.


Original IDFA
29331ADA-5AVT-5Y15–03EG-3659EHIF9103
Zeroed out IDFA
00000000–0000–0000–0000–000000000000


Let's begin with the implementation


We will use the module below called AppTrackingTransparency.



We can check the authorization status with this code below.

ATTrackingManager.trackingAuthorizationStatus


It returns an enum with one of these statuses.

  • notDetermined - The request hasn't been sent to the user yet
  • restricted - The device does not prompt for tracking authorization
  • denied - The user has not consented to the App Tracking
  • authorized - user has consented to the App Tracking


If it returns "notDetermined" it means that we can call requestTrackingAuthorization function in order to present the App Tracking Transparency popup. Before calling this method we have to add "NSUserTrackingUsageDescription" to the info.plist file in order to show the correct message on the popup.


At the end full code must be seen like this below.


ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
     if status == .authorized {
          //do smt
     }
})


Retrieving IDFA


You need to import AdSupport framework in order to access the advertising identifier.


After getting the authorization for the App Tracking Transparency we can retrieve IDFA easily with the code below.


ASIdentifierManager.shared().advertisingIdentifier


I hope that thanks to this article implementing App Tracking Transparency in your iOS apps will be easier than before.


Written by kagangirgin | I'm an ambitious tech addict iOS developer with more than 8 years of experience.
Published by HackerNoon on 2025/07/31