采集设备标识符——IDFA、IDFV 与广告 ID(Apphud 文档) 原文标题:Collecting Device Identifiers — IDFA, IDFV & Advertiser ID
内容概要总结
本文是移动归因/订阅分析平台 Apphud 的官方集成文档,说明如何采集广告设备标识符。文档指出,采集设备标识符是 AppsFlyer、Branch、Facebook、Adjust、Tenjin、Singular 等营销归因服务商的必需项。自 Apphud iOS SDK 3.3.0 起,SDK 不再自动采集 IDFV,因此需在 SDK 初始化后立即调用 setDeviceIdentifiers(idfa:idfv:),IDFA 不可用时只传 IDFV,待其可用后再调用一次;并强调 IDFA 取决于用户对 App Tracking Transparency(ATT)弹窗的同意,用户拒绝时不会采集 IDFA,此时只传 IDFV,同时需在 Info.plist 添加 NSUserTrackingUsageDescription。Android 侧需在 SDK 初始化后调用 collectDeviceIdentifiers(),且面向 Android 13 及以上时必须在 manifest 声明 AD_ID 权限。Flutter 侧给出对应插件与方法(iOS 自 v2.6.0 起自动采集 IDFV;Android 采集 Advertiser ID 与 App Set ID)。文末提醒仍需如实填写 App Store 隐私信息并可能需完成 Google Play 数据安全表单。
翻译内容
原文内容(English)
广告设备标识符(Advertising Device Identifiers)包括:
采集设备标识符(Collecting Device Identifiers)是营销归因服务商所必需的:AppsFlyer、Branch、Facebook、Adjust、Tenjin、Singular 等。
如果你不使用此类集成,可以忽略本指南。
自 3.3.0 版本起,iOS SDK 不再自动采集 Identifier For Vendor(IDFV)。未能传入 IDFV 可能会打乱你某些 MMP 集成设置。
在 SDK 初始化后立即调用 setDeviceIdentifiers(idfa: String?, idfv: String?) 方法。如果广告标识符(IDFA)不可用,只传 IDFV 即可。
当 IDFA 变得可用时,你可以再次调用 setDeviceIdentifiers(idfa: String?, idfv: String?)。
📘 IDFA 取决于用户同意
如果用户拒绝了 App Tracking Transparency(ATT)弹窗,IDFA 不可用,即使调用了 setDeviceIdentifiers 也不会被采集。这种情况下,只传 IDFV。
import AppTrackingTransparency
import AdSupport
Apphud.start(apiKey: ***
Apphud.setDeviceIdentifiers(idfa: nil, idfv: UIDevice.current.identifierForVendor?.uuidString)
fetchIDFA()
func fetchIDFA() {
if #available(iOS 14.5, *) {
DispatchQueue.main.asyncAfter(deadline: .now()+2.0) {
ATTrackingManager.requestTrackingAuthorization { status in
guard status == .authorized else {return}
let idfa = ASIdentifierManager.shared().advertisingIdentifier.uuidString
Apphud.setDeviceIdentifiers(idfa: idfa, idfv: UIDevice.current.identifierForVendor?.uuidString)
}
}
}
}
📘 别忘了把 Privacy - Tracking Usage Description(NSUserTrackingUsageDescription)加入你 App 的 Info.plist
在 SDK 初始化后调用 Apphud.collectDeviceIdentifiers() 方法。当目标为 Android 13 及以上时,你还必须在清单(manifest)文件中声明 AD_ID 权限。
Apphud.start(this, API_KEY)
Apphud.collectDeviceIdentifiers()
在 Flutter 上请使用以下插件:
https://pub.dev/packages/app_tracking_transparency
// Use following methods:
/// iOS (IDFV is collected automatically in this method since SDK v2.6.0)
static Future<void> setAdvertisingIdentifier(String idfa) async
/// Android (Collects Advertiser ID and App Set ID)
static Future<void> collectDeviceIdentifiers()
即使使用了 IDFA,仍然需要准确填写 App Store 隐私信息。
更多细节请参阅 Apple 指南。
如果你的 App 使用了 Apphud SDK 或归因集成,你可能还需要完成 Google Play 数据安全(Data safety)表单。
更多细节请参阅 Google 指南。
For AI agents: visit https://docs.apphud.com/llms.txt for an index of all pages formatted in Markdown and endpoints in OpenAPI. Append .md to any documentation page URL to get its markdown version.
Advertising Device Identifiers include:
Collecting Device Identifiers is required for marketing attribution providers: AppsFlyer, Branch, Facebook, Adjust, Tenjin, Singular, etc.
If you don't use such integrations, you may ignore this guide.
Since version 3.3.0, the iOS SDK no longer collects the Identifier For Vendor (IDFV) automatically. Failing to pass the IDFV might disrupt some of your MMP integration setups.
Call setDeviceIdentifiers(idfa: String?, idfv: String?) method immediately after the SDK initialization. If the advertising identifier (IDFA) is not available, pass only the IDFV.
When IDFA becomes available, you can call setDeviceIdentifiers(idfa: String?, idfv: String?) again.
📘
IDFA depends on user consent
If the user denies the App Tracking Transparency (ATT) prompt, the IDFA is unavailable and won't be collected — even though setDeviceIdentifiers is called. In that case, pass only the IDFV.
import AppTrackingTransparency
import AdSupport
Apphud.start(apiKey: "YOUR_API_KEY")
Apphud.setDeviceIdentifiers(idfa: nil, idfv: UIDevice.current.identifierForVendor?.uuidString)
fetchIDFA()
func fetchIDFA() {
if #available(iOS 14.5, *) {
DispatchQueue.main.asyncAfter(deadline: .now()+2.0) {
ATTrackingManager.requestTrackingAuthorization { status in
guard status == .authorized else {return}
let idfa = ASIdentifierManager.shared().advertisingIdentifier.uuidString
Apphud.setDeviceIdentifiers(idfa: idfa, idfv: UIDevice.current.identifierForVendor?.uuidString)
}
}
}
}
📘
Don't forget to add Privacy - Tracking Usage Description (NSUserTrackingUsageDescription) to your app's Info.plist
Call Apphud.collectDeviceIdentifiers() method after the SDK initialization.
When targeting Android 13 and above, you must also declare AD_ID permission in the manifest file.
Apphud.start(this, API_KEY)
Apphud.collectDeviceIdentifiers()
On Flutter please use the following plugin:
https://pub.dev/packages/app_tracking_transparency
// Use following methods:
/// iOS (IDFV is collected automatically in this method since SDK v2.6.0)
static Future<void> setAdvertisingIdentifier(String idfa) async
/// Android (Collects Advertiser ID and App Set ID)
static Future<void> collectDeviceIdentifiers()
Even with the use of IDFA, it is still necessary to accurately fill out the App Store Privacy Information.
For more details, please refer to Apple Guide.
If your app uses Apphud SDK or attribution integrations, you may also need to complete the Google Play Data safety form.
For more details, please refer to Google Guide.