idfa_idfa和你

idfa

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.

如果本文的标题对您有意义,那么您可能已经意识到iOS14引起的地震。 对于那些不知道的人,在iOS14发行之后,应用程序收集有关用户信息的方式发生了重大变化。 IDFA及其应用程序如何访问是一项重大更改。 简而言之,现在将要求应用程序向用户显示对话框,询问他/她是否允许应用程序跟踪他们。

Image for post
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.

这与iOS14之前的工作方式形成对比,在iOS14之前,您只需要检查设备是否启用或禁用了有限的广告跟踪。

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:

自9月16日以来,Apple操作系统(iOS14)的最新版本已经可用。 使用IDFA的开发人员必须对其应用程序进行更改,才能与iOS14兼容。 9月3日,Apple进行了一次更新,将最早设置在iOS14发布的截止日期推迟到明年年初:

“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.

现在我们有一些时间来恢复镇定状态并再次呼吸,让我们不要浪费时间并开始为2021年的新常态做好准备。

什么是IDFA? (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).

每个iOS设备所有者可以选择是否要被广告公司跟踪,以便为该用户提供针对他们的内容(基于他们的在线浏览习惯)。

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.

使用所谓的IDFA(广告客户标识符)。 这是一个UUID字符串,可让广告客户将用户与其行为进行匹配。

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

UUID示例: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.

那么广告商如何使用IDFA? 让我们假设一个场景(COIVD19之前的版本),您正在iPhone上浏览网页,并在寻找下一个假期的酒店。 您看到的每个广告都会发送一个像素,并附加您的IDFA。 通过匹配您的IDFA,广告客户可以看到您正在查看许多宣传酒店的广告,并得出结论,您正在预订酒店。 从那里开始,不久之后您就会看到许多关于酒店客房的广告。

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.

这种简单而深刻的技术性早在2012年借助iOS6进入了我们的生活。 从那时起,发生了很多变化,iOS14再次颠覆了整个行业。

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

✋要使用这些新API,您必须已升级/下载了XCode 12

广告跟踪和获取IDFA (Advertising Tracking And Getting The IDFA)

Before iOS14, getting the IDFA was pretty simple.

在iOS14之前,获取IDFA非常简单。

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

您必须执行以下步骤检查是否启用了广告跟踪

[[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]

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

如果禁用了它,则意味着您可以通过ASIdentifierManager类获取IDFA,如下所示:

[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];

Simple enough, right?

很简单,对不对?

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

iOS️从iOS10开始,如果用户禁用广告跟踪,则上述方法将返回填充有零的UUID字符串。

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?

iOS14中的一项更改是不赞成使用检查广告客户跟踪功能的方法。 那么应用程序如何才能从iOS14及更高版本中获得梦the以求的IDFA?

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

他们将不得不使用一个新的API向用户显示对话框。 关于此对话框的几点智慧:

  • 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 :

借助iOS14,已创建了一个称为App Tracking Transparency的新框架。 该框架包含一个名为ATTrackingManager的类,该类提供了以下功能的API:

  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.

我们将首先展示如何获取授权状态。 为此,您需要调用trackingAuthorizationStatus方法。

ATTrackingManagerAuthorizationStatus status = [ATTrackingManager trackingAuthorizationStatus];

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

它将返回具有以下值之一的NSUInteger:

  • ATTrackingManagerAuthorizationStatusNotDetermined = 0

    ATTrackingManagerAuthorizationStatusNotDetermined = 0
  • ATTrackingManagerAuthorizationStatusRestricted = 1

    ATTrackingManagerAuthorizationStatusRestricted = 1
  • ATTrackingManagerAuthorizationStatusAuthorized = 3

    ATTrackingManagerAuthorizationStatusAuthorized = 3
  • ATTrackingManagerAuthorizationStatusDenied = 2

    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.

在研究呈现对话框所需的代码之前,必须首先在info.plist文件中包括NSUserTrackingUsageDescription键。 您添加为该键的值的内容将在对话框中显示为前面提到的两行。

Image for post
NSUserTrackingUsageDescription in the info.plist file info.plist文件中的NSUserTrackingUsageDescription

To present the dialog, we need to call requestTrackingAuthorizationWithCompletionHandler:

要显示对话框,我们需要调用requestTrackingAuthorizationWithCompletionHandler

[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
        if (status == ATTrackingManagerAuthorizationStatusDenied) {
            //Logic when authorization status is denied
        } else if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
            //Logic when authorization status is authorized
        } else if (status == ATTrackingManagerAuthorizationStatusNotDetermined) {
            //Logic when authorization status is unknown
        }  else if (status == ATTrackingManagerAuthorizationStatusRestricted) {
            //Logic when authorization status is restricted
        }
    }];

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.

在本文的第一张图中,您可以看到对话框,您可以看到我们在info.plist文件中编写的行显示为对话框中的两行。

翻译自: https://medium.com/macoclock/idfa-and-you-7907c7336119

idfa

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值