-1

I wanted to implement google ads into my unity app with the official package (version 5.4.0, unity version is 2019.4.14):
https://github.com/googleads/googleads-mobile-unity/releases
When I run the project in the editor, the test ad is displayed. But when I build the app and install it on my phone, it doesn't show anything (my WiFi connection is good and I have access to Google services).
My ad manager:
using System;
using System.Collections;
using UnityEngine;
using GoogleMobileAds.Api;

public class AdsManager : MonoBehaviour
{
    private static readonly string appId = "ca-app-pub-3940256099942544/3419835294";
    private static readonly string bannerId = "ca-app-pub-3940256099942544/6300978111";
    private static readonly string interstitialId = "ca-app-pub-3940256099942544/1033173712";
    private static readonly string rewardedId = "ca-app-pub-3940256099942544/5224354917";
    private static readonly string rewardedInterstitialId = "ca-app-pub-3940256099942544/5354046379";
    private static readonly string nativeId = "ca-app-pub-3940256099942544/2247696110";

    private InterstitialAd interstitialAd;

    void Start()
    {
        MobileAds.Initialize(InitializationStatus => {});
        this.RequestInterstitial();
    }

    public AdRequest CreateAdRequest() {
        return new AdRequest.Builder().Build();
    }

    public void RequestInterstitial() {
        Debug.Log("Requesting interstitial ad");
        if(this.interstitialAd != null) {
            this.interstitialAd.Destroy();
        };

        this.interstitialAd = new InterstitialAd(interstitialId);
        this.interstitialAd.OnAdClosed += HandleOnInterstitialAdClosed;

        this.interstitialAd.LoadAd(this.CreateAdRequest());

        ShowInterstitial();
    }

    public void ShowInterstitial() {
        if(this.interstitialAd.IsLoaded()) {
            this.interstitialAd.Show();
        } else {
            this.RequestInterstitial();
        }
    }

    public void HandleOnInterstitialAdClosed(object sender, EventArgs args)
    {
        Debug.Log("Closed interstitial ad");
    }
}

I tried using the Android LogCat but it didn't find any mention of "Requesting interstitial ad". I get this log in the editor though and the test ad is shown. Any idea what is the issue?
Thanks

Pandicon
  • 420
  • 1
  • 15
  • 38

1 Answers1

1

1 - The editor always shows test ads, after all when you use the app on the editor, you are testing it.

2 - If you want to display test ads on the device where you have installed the app, there are two ways: the first is to define your device as a test device in AdMob, the second to use strings for test ad units (https: //developers.google.com/admob/unity/test-ads#android)

3 - If you want to view real ads instead (be careful, if you see too many ads that you publish yourself and / or click them, you may have invalid traffic problems, so it is always better to view them as test ads), the real ads come to the end of a process:

First you need to create the app with the official app ID and ad unit strings that you get from the AdMob page for your app. Then you have to upload the app to a supported store, then you have to connect the app of the store to the app on AdMob, then the AdMob team performs a review on your app to verify that you are in order at a legal and regulatory level. , and eventually you will have your real, monetizable ads.

Francesco - FL
  • 603
  • 1
  • 4
  • 25