[英]How to integrate “Tracking Transparency” and “EU Consent” in Google Admob in Swift/iOS?
我正在嘗試在 Swift 中使用“跟蹤透明度”和“歐盟同意”來實現 Admob。
我的應用程序適用於 iOS 14.0+ 設備,因此我已按照https://developers.google.com/admob/ios/ios14上的說明進行操作。 為了遵守歐盟對 GDPR 的同意,我實施了https://developers.google.com/admob/ump/ios/quick-start的說明(這是歐盟同意的當前實施,而不是舊實施。)。
之后,第一次啟動應用程序后會顯示“跨設備跟蹤用戶”對話框。 之后,將顯示歐盟同意對話框。 一切正常。
我的問題是,我的實施是否有效,以便當 Google 初始化 Admob 時,它會通過跟蹤透明度和歐盟同意設置尊重用戶的偏好?
這是我的代碼:
import SwiftUI
import GoogleMobileAds
import AppTrackingTransparency
import UserMessagingPlatform
@main
struct SampleAdmobWithEuConsent: App {
init() {
requestIDFA()
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
private func initGoogleMobileAds() {
GADMobileAds.sharedInstance()
.start(completionHandler: nil)
}
private func requestIDFA() {
ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
// Tracking authorization completed. Start loading ads here.
showConsentInformation()
})
}
private func showConsentInformation() {
let parameters = UMPRequestParameters()
// false means users are not under age.
parameters.tagForUnderAgeOfConsent = false
UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(
with: parameters,
completionHandler: { error in
if error != nil {
// Handle the error.
} else {
// The consent information state was updated.
// You are now ready to check if a form is
// available.
loadForm()
}
})
}
func loadForm() {
UMPConsentForm.load(
completionHandler: { form, loadError in
if loadError != nil {
// Handle the error
} else {
// Present the form
if UMPConsentInformation.sharedInstance.consentStatus == UMPConsentStatus.required {
form?.present(from: UIApplication.shared.windows.first!.rootViewController! as UIViewController, completionHandler: { dimissError in
if UMPConsentInformation.sharedInstance.consentStatus == UMPConsentStatus.obtained {
// App can start requesting ads.
initGoogleMobileAds()
}
})
}
}
})
}
}
我在 GADMobileAds.sharedInstance() 中找不到根據對話框中用戶的偏好設置指定設置的方法。 (例如:跨應用跟蹤我或向我展示個性化廣告)。
提前致謝!
我遵循了您的代碼示例,當我在模擬器上進行測試時,我從未獲得歐盟同意對話框。 雖然我 select 允許在第一個對話框中進行跟蹤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.