【问题标题】:iOS / Admob 7.20 - Can't get Native ads to show using the test adUnitIDiOS / Admob 7.20 - 无法使用测试 adUnitID 显示原生广告
【发布时间】:2017-10-08 02:32:58
【问题描述】:

我设置了一个非常简单的视图控制器,主要目的是尝试使用 Google Mobile Ads 7.20.0 运行测试原生广告。

使用下面发布的我的代码,Google 在其 Admob 存储库中提供的测试 adUnitID 不起作用。从来没有广告。但是,如果我使用生产 adUnitID,它显示得很好。我需要测试广告以用于开发目的。我没有使用 Firebase。

import GoogleMobileAds
import UIKit

class ViewController: UIViewController {

    let testID = "ca-app-pub-3940256099942544/8897359316"

    @IBOutlet weak var adView: GADNativeExpressAdView! // Using storyboard here.

    override func viewDidLoad() {
        super.viewDidLoad()

        adView.adUnitID = testID
        adView.rootViewController = self
        let request = GADRequest()
        request.testDevices = [kGADSimulatorID]
        adView.load(request)

    }

}

这是打印到控制台的内容

[DYMTLInitPlatform] platform initialization successful
[MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
[MC] Reading from public effective user settings.
<Google> To get test ads on this device, call: request.testDevices = @[ @"abc123" ];
Metal GPU Frame Capture Enabled
Metal API Validation Enabled
libMobileGestalt MobileGestaltSupport.m:153: pid 1983 (Native Admob Test) does not have sandbox access for frZQaeyWLUvLjeuEK43hmg and IS NOT appropriately entitled
libMobileGestalt MobileGestalt.c:550: no access to InverseDeviceID (see <rdar://problem/11744455>)

上面有什么明显的地方吗? 如何让 Google 测试广告 ID 与 Native Ad Express 一起使用?

【问题讨论】:

  • 这里还有一点发现... 结果,我的原生横幅视图有 100 高(在故事板中)。我将其更改为 300 并且上面的代码运行良好。看起来我只需要获得一个为“小模板”原生横幅配置的谷歌测试 adUnitID。所以现在是百万美元的问题:)
  • 您是否给了 GoogleAd 的代表?

标签: ios swift admob native-ads


【解决方案1】:

通过将您的测试设备 ID 添加到您的 GADRequest 来使用测试广告。

您的测试设备 ID 会在您的控制台中打印出来:

<Google> To get test ads on this device, call: request.testDevices = @[ @"abc123" ];

将其添加到您的GADRequest

let request = GADRequest()
request.testDevices = [kGADSimulatorID, "abc123"]

【讨论】:

  • testDevices 不适用于原生广告。仅适用于横幅和插页式广告。 (我本可以直接在 load 方法中调用 GADRequest(),但这只是使用横幅和插页式广告的习惯。)获得测试广告的唯一方法是使用 Google 的测试 adUnitID。
  • 很高兴知道。不知道它不适用于原生广告。我建议您联系 AdMob。
【解决方案2】:

我遇到此问题的原因是我使用的“GADNativeExpressAdView”的大小。它落入“小模板”的约束 - 谷歌仓库上的测试 adUnitID 是针对大模板的。

我需要做的就是将 adUnitID 更改为 Small Template 测试 ID 以显示测试横幅:

Android:ca-app-pub-3940256099942544/2793859312

iOS:ca-app-pub-3940256099942544/4270592515

【讨论】:

    猜你喜欢
    • 2016-09-06
    • 1970-01-01
    • 1970-01-01
    • 2018-01-06
    • 1970-01-01
    • 1970-01-01
    • 2020-09-06
    • 2018-07-09
    • 2016-09-19
    相关资源
    最近更新 更多