0

I have a very simple View Controller set up for the main purpose of trying to get the test Native ads running, using Google Mobile Ads 7.20.0.

With my code that's posted below, the test adUnitID that Google provides in their Admob repo does not work. No ads ever show. If I use the production adUnitID, however, it shows fine. I need the test ads to show for development purposes. I'm not using 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)

    }

}

Here's what prints out to the console

[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>)

Does anything look glaringly off in the above? What can I do to get the Google test ad ID working with Native Ad Express?

Joe
  • 3,772
  • 3
  • 33
  • 64
  • A little more discovery here... Turns out, my native banner view was 100 tall (in storyboard). I changed it to 300 and the above code worked fine. Looks like I just need to get my hands on a google test adUnitID that's configured for "Small Template" native banners. So that's now the million dollar question :) – Joe May 09 '17 at 18:39
  • Did you gave delegate of GoogleAd? – Jitendra Modi May 10 '17 at 05:10

2 Answers2

0

Use test ads by adding your test device ID to your GADRequest.

Your test device ID is printed out in your console:

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

Add that to your GADRequest:

let request = GADRequest()
request.testDevices = [kGADSimulatorID, "abc123"]
Daniel Storm
  • 18,301
  • 9
  • 84
  • 152
  • testDevices does not work with Native Ads. Just for Banners and Interstitials. (I could have just called GADRequest() directly in the load method, but it's just habit from using banners and interstitials.) The only way you can get test ads is using Google's test adUnitID. – Joe May 09 '17 at 18:36
  • Good to know. Wasn't aware that it didn't work with native ads. I'd suggest contacting AdMob then. – Daniel Storm May 09 '17 at 18:39
0

The reason I was experiencing this issue is due to the size of the 'GADNativeExpressAdView' I was working with. It fell into the constraints of the "Small Template" - and the test adUnitID's that are on googles repo are for Large Template.

All I needed to do was change the adUnitID's to the Small Template test ID for the test banners to show up:

Android: ca-app-pub-3940256099942544/2793859312

iOS: ca-app-pub-3940256099942544/4270592515

Joe
  • 3,772
  • 3
  • 33
  • 64