0

我设置了一个非常简单的视图控制器,主要目的是尝试使用 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 一起使用?

4

2 回答 2

0

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

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

安卓:ca-app-pub-3940256099942544/2793859312

iOS:ca-app-pub-3940256099942544/4270592515

于 2017-05-09T23:47:41.420 回答
0

通过将您的测试设备 ID 添加到您的GADRequest.

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

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

将其添加到您的GADRequest

let request = GADRequest()
request.testDevices = [kGADSimulatorID, "abc123"]
于 2017-05-09T18:29:48.827 回答