首页 > 解决方案 > 为什么 admob 同意书未在实际设备上加载?

问题描述

我正在尝试为我的 iOS 应用程序实现 Admob。表单加载到 Xcode 模拟器设备上。我位于美国,但我使用以下代码来测试 Consent SDK 是否适用于欧洲用户。当我将它与模拟器一起使用时,会加载表单和广告。

PACConsentInformation.sharedInstance.debugIdentifiers = ["SPECIFIC_TO_MY_DEVICE"]
PACConsentInformation.sharedInstance.debugGeography = PACDebugGeography.EEA

使用此配置,表单不会加载到我的物理设备上。testflight当我过去将测试版本分发给欧盟的测试用户时,该表单也没有加载。随后,广告没有在“欧洲”设备上加载。

当表单应该加载时,我从下面的代码块中得到一个错误。还。我得到错误WebKitDomain Error 101。我的 ATS 设置是在plist每个 Admob 文档中设置的。

thisForm.load {(_ error: Error?) -> Void in
    if let error = error {
        print("Error loading form: \(error.localizedDescription)")
        //I am getting the error here.
    } else {
        thisForm.present(from: self) { (error, userPrefersAdFree) in
            print("in present handler")
            if let error = error {
                // Handle error.
                print("error presenting: \(error.localizedDescription)")
            } else if userPrefersAdFree {
                //TODO: find a way to disable ads
            } else {
                // Check the user's consent choice.
                //let status = PACConsentInformation.sharedInstance.consentStatus
            }
        }
    }

有谁知道物理设备可能导致这些错误的原因是什么?我尝试过使用真实的广告 ID 和测试广告 ID。

标签: iosswiftadmob

解决方案


仅在以下情况为真时出示同意书

If requestLocationInEEAOrUnknown == true {
//present consent form
}
else {
//do whatever is needed
}

推荐阅读