Photo by Markus Winkler on Unsplash

IDFA And You

tomerpacific
Mac O’Clock
Published in
4 min readSep 19, 2020

--

If the title of this article means something to you, then you are probably aware of the earthquake caused by iOS14. For those that are unaware, following the release of iOS14, there are major changes in the way applications can gather information about the user. One major change deals with the IDFA and how applications can access it. In short, applications will now be required to show a dialog to the user, asking him/her if they allow the application to track them or not.

The Tracking Authorization Dialog

Looks pretty ominous, right?

This comes in contrast with how things worked before iOS14, where you only had to check if the device had limited advertising tracking enabled or disabled.

The newest version of Apple’s operating system (iOS14) is already available since September 16th. Developers who use the IDFA have to make changes in their applications in order to be compatible for iOS14. On September 3rd, Apple made an update, pushing the deadline first set to be with the release of iOS14, to the start of next year:

“To give developers time to make necessary changes, apps will be required to obtain permission to track users starting early next year”

Now that we have some time to regain our composure and be able to breathe again, let’s not waste it and start preparing ourselves for what’s going to be the new normal in 2021.

What is IDFA?

Each iOS device owner can make a choice if he/she wants to be tracked by advertising companies for the purpose of supplying that user with content that is tailored towards them (based on their online browsing habits).

How can applications track this user?

With what’s known as an IDFA (Identifier For Advertisers). This is a UUID string that can let advertisers match the user with his/her behavior.

UUID example : 123e4567-e89b-12d3-a456–426614174000

So how does the IDFA get used by advertisers? Let’s take a scenario (pre COIVD19) where you are browsing the web on your iPhone and are looking for a hotel for your next vacation. Each ad that you see, will send a pixel with your IDFA attached to it. An advertiser can see that you are looking at a lot of ads promoting hotels by matching your IDFA and conclude that you are looking to book a hotel room. From there, it won’t be long till you will be shown a lot of ads for hotel rooms.

This simple yet profound technicality has come into our lives back in 2012 with iOS6. Since then a lot has changed, and iOS14 is flipping the industry on it’s head, yet again.

✋ To use these new APIs you must have upgraded/downloaded XCode 12

Advertising Tracking And Getting The IDFA

Before iOS14, getting the IDFA was pretty simple.

You had to check whether Advertising Tracking was enabled or not, by doing this:

Checking If LAT is enabled or disabled

And if it was disabled, that meant you could acquire the IDFA through the ASIdentifierManager class, like so:

Getting the IDFA

Simple enough, right?

☝️ Beginning from iOS10, if the user disabled advertising tracking, the method above would return a UUID string filled with zeros.

One of the changes in iOS14 is the deprecation of the method that checks whether advertiser tracking is enabled or not. So how can applications get the coveted IDFA from iOS14 and onward?

They will have to use a new API that presents a dialog to the user. A few words of wisdom regarding this dialog:

  • It can only be presented to the user once
  • The only thing that can be altered in the dialog’s UI are the two lines above the Allow Tracking option (“Do you want to be tracked?”)

This means that developers will need to think hard and long about how and when they will be presenting it to the user.

Authorization Status

With iOS14 a new framework has been created, called App Tracking Transparency. This framework contains a class called, ATTrackingManager, which provides an API to :

  1. Present a dialog to the user requesting permission to track him/her
  2. Query the authorization status (regardless of showing or not showing the dialog)

We’ll first show how to get the authorization status. To do so, you need to call the trackingAuthorizationStatus method.

It will return an NSUInteger with one of the following values:

  • ATTrackingManagerAuthorizationStatusNotDetermined = 0
  • ATTrackingManagerAuthorizationStatusRestricted = 1
  • ATTrackingManagerAuthorizationStatusAuthorized = 3
  • ATTrackingManagerAuthorizationStatusDenied = 2

The first three results are pretty self explanatory, so we will focus for a minute on the last one. Getting an authorization status that is restricted can result from the scenario when the screen for enabling/disabling advertising tracking is locked and this option is set to eanbled. This is something Apple has confessed to happening in devices that are identified as belonging to children (for example).

Asking For Permission To Track

Before looking into the code needed to present the dialog, you must first include the NSUserTrackingUsageDescription key inside your info.plist file. What you add as the value for this key will appear as the two lines mentioned earlier, in the dialog.

NSUserTrackingUsageDescription in the info.plist file

To present the dialog, we need to call requestTrackingAuthorizationWithCompletionHandler:

Showing the dialog and enacting logic based on user’s decision

In the first picture of this article, where you see the dialog, you can see that the lines we wrote in the info.plist file, show up as the two lines in the dialog.

--

--