Prepare IDFA for iOS14

In June 2020, Apple announced an update to iOS 14 requiring apps to ask users for permission to access Apple’s identifier for advertisers (IDFA) through a prompt called App Tracking Transparency (ATT) framework. We are sharing our recommendations for how you can prepare for the changes and help protect your ad revenue.

可能許多開發者收到Google AdMob通知訊息,為了迎接iOS14,需升級SDK並且為您的App添加設置。

在iOS14之前,無法詢問權限,預設啟用IDFA,但使用者可在設定關閉;而在iOS14之後,需要詢問IDFA權限,才得以取得資訊。

若未能取得IDFA,則無法投放個人化廣告,隨機投放方式,可能使用者對於廣告較沒興趣,點擊率會降低,收益也會跟隨降低。

。前置作業:

確定已安裝以下套件

pod ‘Google-Mobile-Ads-SDK’  //需為SDK 7.64.0 以上版本,最低iOS9以上pod ‘Firebase/AdMob’

若已安裝過Google-Mobile-Ads-SDK,則進行更新

pod update Google-Mobile-Ads-SDK

。info.plist 添加IDFA詢問權限、SKAdNetwork追蹤

其中SKAdNetworkItems可參考Google AdMob 已列出對應identifier。

以下列出cstr6suwn9.skadnetwork 為AdMob。

Privacy — Tracking Usage Description : 填寫Alert message 內容<key>SKAdNetworkItems</key>
<array>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>cstr6suwn9.skadnetwork</string>
</dict>
</array>
info.plist
簡易對照表

。程式碼添加詢問權限:

requestTrackingAuthorization(completionHandler:)會詢問權限,建議在didFinishLaunching時進行詢問追蹤權限。

Objective-C

Swift

詢問權限訊息:message內容為info.plist所填寫。

Ask App not to Track:拒絕追蹤

Allow:同意追蹤

。值得注意:

  1. Setting -> Privacy -> Tracking -> Allow Apps to request to track 此設定未開啟時,App未決定時,則不會觸發詢問視窗。
  2. 每次重啟IDFA設定時,會得到新的IDFA。故此值非固定。
  3. 並非唯模擬器回傳0,幾種情況下會得到zeros 00000,官方文件已列出
iOS 14

。IDFA 流程圖:

覺得有幫助的話,幫我拍個手手,有機會再繼續寫下去。

可以幫我按讚,也可以與我分享一杯咖啡來支持我。

--

--

奇妙仙子
彼得潘的 Swift iOS / Flutter App 開發教室

When you want something, all the universe conspires in helping you to achieve it.