【问题标题】:Admob IOS swift GDPR consentAdmob IOS swift GDPR 同意
【发布时间】:2020-02-17 00:11:28
【问题描述】:

我是 swift 和 iOS 编程的新手。我想在我的应用中添加 Admob 同意/GDPR 选项, 所以我设置了一个广告框,可以显示一个测试添加,但接下来需要添加同意选项。

我读过 https://developers.google.com/admob/ios/eu-consent

但我不清楚,谁能给我一个逐步执行此操作的代码示例,或将我指向已完成的 GitHub 源代码。

谢谢

【问题讨论】:

  • 你在哪一步?该指南非常直接地说明了需要做什么。

标签: ios swift admob admob-cookieconsent


【解决方案1】:

您能否举例说明您尝试过但对您不起作用的方法?

由于我无法查看您的代码示例来了解您在做什么或不做什么,我将根据文档给出一个示例。

import PersonalizedAdConsent

...

class ViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()

    PACConsentInformation.sharedInstance.
    requestConsentInfoUpdate(
    forPublisherIdentifiers: ["pub-0123456789012345"])
    {(_ error: Error?) -> Void in
      if let error = error {
        // Consent info update failed.
      } else {
        // Consent info update succeeded. The shared PACConsentInformation
        // instance has been updated.
      }
    }

guard let privacyUrl = URL(string: "https://www.your.com/privacyurl"),
  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 {
    // Load successful.
  }
}

//Finally present the consent form
form.present(from: self) { (error, userPrefersAdFree) in
      if let error = error {
        // Handle error.
      } else if userPrefersAdFree {
        // User prefers to use a paid version of the app.
      } else {
        // Check the user's consent choice.
        let status =
             PACConsentInformation.sharedInstance.consentStatus
      }
    }

      } 

【讨论】:

  • 所以此刻我的 viewController.swift 将测试横幅代码显示为 320x50 UIVIEW 可以工作,我更新了 Podfiles 添加:PersonalizedAdConsent,可以使用,但我不知道如何使用它 ?我试过谷歌,但找不到任何奇怪的例子,因为我认为任何使用 Admob 的人都必须这样做
  • 由于我无法查看您的代码示例来了解您在做什么或不做什么,我将根据谷歌在他们的文档中提供的内容进行解释。
  • 感谢更新我会试试这个我还在 git 上找到了参考:github.com/crashoverride777/swifty-ad,我也会尝试,
  • 错误域=同意代码=1“未加载表单。” UserInfo={NSLocalizedDescription=表单未加载。} ???
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-10-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多