iOS / Admob 7.20 - 无法使用测试adUnitID显示原生广告

时间:2017-05-09 16:49:35

标签: ios swift admob native-ads

我设置了一个非常简单的View Controller,主要目的是尝试使用Google移动广告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配合使用?

2 个答案:

答案 0 :(得分:0)

将测试设备ID添加到GADRequest

,以使用测试广告

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

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

将其添加到您的GADRequest

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

答案 1 :(得分:0)

我遇到此问题的原因是由于GADNativeExpressAdView&#39; GADNativeExpressAdView&#39;我正在和我一起工作。它陷入了“小模板”的限制。 - 谷歌回购中的测试adUnitID用于大型模板。

我需要做的就是将adUnitID更改为小模板测试ID,以便显示测试横幅:

Android:ca-app-pub-3940256099942544/2793859312

iOS:ca-app-pub-3940256099942544/4270592515