gpt4 book ai didi

ios - AdMob同意书未显示吗?

转载 作者:行者123 更新时间:2023-12-01 15:57:49 25 4
gpt4 key购买 nike

我不明白为什么未显示Google提交的同意书。它说它已成功加载,但随后没有显示。 (我在欧洲,所以我的位置不是问题)。我已经在模拟器和真实设备上进行了尝试,我仅手动选择了12个广告提供商。

这是有问题的代码:

PACConsentInformation.sharedInstance.debugIdentifiers = ["4FDF7D7F-8F56-4E65-8570-103100943386"]
PACConsentInformation.sharedInstance.debugGeography = PACDebugGeography.EEA


PACConsentInformation.sharedInstance.requestConsentInfoUpdate(forPublisherIdentifiers: ["pub-5765803665103285"]){

(_ error: Error?) -> Void in
if let error = error {
// Consent info update failed.
print(error)
} else {
// Consent info update succeeded. The shared PACConsentInformation
// instance has been updated.

if PACConsentInformation.sharedInstance.consentStatus == PACConsentStatus.unknown {

guard let privacyUrl = URL(string: "http://www.gdgapps.altervista.org/index.html/gdg-privacy.html"),
let form = PACConsentForm(applicationPrivacyPolicyURL: privacyUrl) else {
print("incorrect privacy URL.")
return
}
form.shouldOfferPersonalizedAds = true
form.shouldOfferNonPersonalizedAds = true
form.shouldOfferAdFree = true

form.load {(_ error: Error?) -> Void in
print("Load complete.")
if let error = error {
// Handle error.
print("Error loading form: \(error.localizedDescription)")
} else {

print("Load successful.")
}
}

form.present(from: self) { (error, userPrefersAdFree) in

if error != nil {
// Handle error.
} else if userPrefersAdFree {
// User prefers to use a paid version of the app.

//TODO: buy pro version
} else {
// Check the user's consent choice.
let status = PACConsentInformation.sharedInstance.consentStatus

// TODO: show ads
}
}
} else if PACConsentInformation.sharedInstance.consentStatus == PACConsentStatus.nonPersonalized || PACConsentInformation.sharedInstance.consentStatus == PACConsentStatus.personalized{

print("ads")

self.bannerView.isHidden = false
self.tableBasso.constant = 50
self.bannerView.adUnitID = "ca-app-pub-5765803665103285/9440944250"
self.bannerView.rootViewController = self

let request = GADRequest()

if PACConsentInformation.sharedInstance.consentStatus == PACConsentStatus.nonPersonalized {

let extras = GADExtras()
extras.additionalParameters = ["npa": "1"]
request.register(extras)
}

self.bannerView.load(request)
}
}
}
}

最佳答案

加载后,应显示形式。将form.present放入form.load的完成块中。

form.load { [weak self] error in
print("Load complete.")
if let error = error {
print("Error loading form: \(error.localizedDescription)")
} else {
guard let strongSelf = self else { return }
form.present(from: strongSelf) { error, userPrefersAdFree in
[...]
}
}
}

关于ios - AdMob同意书未显示吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51427003/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com