【发布时间】:2022-10-13 14:28:50
【问题描述】:
我正在将 UMP SDK 实施到我的 iOS 应用程序中。我在 Google AdMob 信息中心的隐私和消息部分设置了 GDPR 和 IDFA 消息。我无法显示 GDPR 消息。 IDFA 和 iOS 的 ATT 消息完美运行。
下面是我正在使用的代码。我已经在模拟器和物理设备上对此进行了测试。另外,我位于欧盟。
static func trackingConsentFlow(completion: @escaping () -> Void) {
let umpParams = UMPRequestParameters()
let debugSettings = UMPDebugSettings()
debugSettings.geography = UMPDebugGeography.EEA
umpParams.debugSettings = debugSettings
umpParams.tagForUnderAgeOfConsent = false
UMPConsentInformation
.sharedInstance
.requestConsentInfoUpdate(with: umpParams,
completionHandler: { error in
if error != nil {
print("MYERROR #1 \(String(describing: error))")
completion()
} else {
let formStatus = UMPConsentInformation.sharedInstance.formStatus
print("FORM STATUS: \(formStatus)")
if formStatus == .available {
loadForm(completion)
} else {
completion()
}
}
})
}
private static func loadForm(_ completion: @escaping () -> Void) {
UMPConsentForm.load(completionHandler: { form, loadError in
if loadError != nil {
print("MYERROR #2 \(String(describing: loadError))")
completion()
} else {
print("CONSENT STATUS: \(UMPConsentInformation.sharedInstance.consentStatus)")
if UMPConsentInformation
.sharedInstance.consentStatus == .required {
guard let rootViewController = UIApplication.shared.currentUIWindow()?.rootViewController else {
return completion()
}
form?.present(from: rootViewController, completionHandler: { dismissError in
if UMPConsentInformation
.sharedInstance.consentStatus == .obtained {
completion()
}
})
}
}
})
}
只是要清楚:
使用此代码,我可以显示 IDFA 消息,然后显示 AppTrackingTransparency 警报。但我希望也能看到 GDPR 同意书。
【问题讨论】:
标签: ios swift admob gdprconsentform ump