Search code examples
c#unity-game-engineadmob

Admob Interstitial ad not showing up at all


I basically copy-pasted and mildly modified the demo project ads setup by the official branch of this Google Mobile Ads and my banner ads show up all right, but no interstitial ads show up - no matter what.

Here's what I did, using my AdManager static class:

This InitializeAds() is called right after starting the game:

public static void InitializeAds()
{
    MobileAds.Initialize(appID);
}

And of course, every level where there is an ad, has the following GetSomeAdRequests() inside their Start() method.

public static void GetSomeAdRequests()
{
    AdRequestBANNER = CreateAdRequest();
    AdRequestINTERST = CreateAdRequest();
}

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

Needless to say I use the tester video and banner IDs provided by Google.

Next, my RequestInterstitial:

public static void RequestInterstitial()
{
    // These ad units are configured to always serve test ads.
    #if UNITY_EDITOR
    string adUnitId = "unused";
    #elif UNITY_ANDROID
    string adUnitId = videoID;
    #else
    string adUnitId = "unexpected_platform";
    #endif

    // Clean up interstitial ad before creating a new one.
    if (interstitial != null)
    {
        interstitial.Destroy();
    }

    // Create an interstitial.
    interstitial = new InterstitialAd(adUnitId);

    // Register for ad events.
    interstitial.OnAdLoaded += HandleInterstitialLoaded;
    interstitial.OnAdFailedToLoad += HandleInterstitialFailedToLoad;
    interstitial.OnAdOpening += HandleInterstitialOpened;
    interstitial.OnAdClosed += HandleInterstitialClosed;
    interstitial.OnAdLeavingApplication += HandleInterstitialLeftApplication;

    // Load an interstitial ad.
    interstitial.LoadAd(AdRequestINTERST);
    if (interstitial.IsLoaded())
    {
        interstitial.Show();
    }
}

And finally AdRequestINTERST is:

private static AdRequest adRequestINTERST;
public static AdRequest AdRequestINTERST
{
    get
    {
        if (adRequestINTERST == null)
        {
            adRequestINTERST = CreateAdRequest();
        }
        return adRequestINTERST;
    }
    set
    {
        adRequestINTERST = value;
    }
}

implemented this way to make sure the request is never null.

Now, I do give a lot of time for the vid to initialize, as it should load upon leve start, but it still doesn't do anything. No error, no freeze.

In the editor play, I tested it using Debug.Log and it reaches the code to actually call the ad. It just doesn't show up, whereas the banner ad works fine.

Any ideas?


Solution

  • I think I got it now.

    So the way I could make this work is this:

    I load the ads when I initialize the scene, or, to be exact, start the request right beforehand. and hide them after the load.

    And when I want the ads to show up, I just call the Show() method and boom, they are there.

    My issue what that the internet speed ain't the best around here and I requested and wanted to show right after the request which won't happen.