iOS / Admob 7.20 – 无法使用testingadUnitID显示原生广告

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

我的代码如下所示,Google在Admob回购中提供的testingadUnitID不起作用。 没有广告显示。 如果我使用生产adUnitID,但是,它显示罚款。 我需要testing广告来展示用于开发的目的。 我没有使用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>) 

在上面有什么看起来很明显吗? 我能做些什么来获得Googletesting广告ID与Native Ad Express的配合?

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

您的testing设备ID将打印在控制台中:

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

将其添加到您的GADRequest

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

我遇到这个问题的原因是由于我正在使用的“GADNativeExpressAdView”的大小。 它陷入了“小模板”的限制 – 而且在谷歌回购testingadUnitID是大模板。

我需要做的就是将adUnitID更改为小模板testingID,以显示testing标题:

Android:ca-app-pub-3940256099942544/2793859312

iOS:ca-app-pub-3940256099942544/4270592515

Interesting Posts