Admob Interstitial showing only once, driving me crazy

I give up and ask here.
I’ve been struggleing with this for days now. Admob plugin works just fine. Banner shows as it should and Interstitial as well … but only once.

I realize that the interstitial needs to be destroyed manually (and I assume created/loaded again after that), but just can’t get it to work.

here’s the basic code I use.

    private InterstitialAd interstitial;
    int admobNumber;
   
   
    void Start()
    {
        DontDestroyOnLoad(this);
        RequestInterstitial ();
       
       
    }

    void Update()
    {
        admobNumber = PlayerPrefs.GetInt("AdmobInt")%10;
        if (admobNumber == 5) {
            ShowInterstitial();
            Debug.Log("showing interstitial");
            PlayerPrefs.SetInt("AdmobInt",PlayerPrefs.GetInt("AdmobInt")+1);
            Debug.Log(PlayerPrefs.GetInt("AdmobInt"));
        }

        /*if (admobNumber == 9) {
            interstitial.Destroy();
            //RequestInterstitial ();
        }  */
    }

    private void RequestInterstitial()
    {
        #if UNITY_EDITOR
        string adUnitId = "unused2";
        #elif UNITY_ANDROID
        string adUnitId = "ca-app-pub-XXXXXXXXXXXXX";
        #elif UNITY_IPHONE
        string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE";
        #else
        string adUnitId = "unexpected_platform";
        #endif
        // Create an interstitial.
        interstitial = new InterstitialAd(adUnitId);
        // Register for ad events.
        interstitial.AdLoaded += HandleInterstitialLoaded;
        interstitial.AdFailedToLoad += HandleInterstitialFailedToLoad;
        interstitial.AdOpened += HandleInterstitialOpened;
        interstitial.AdClosing += HandleInterstitialClosing;
        interstitial.AdClosed += HandleInterstitialClosed;
        interstitial.AdLeftApplication += HandleInterstitialLeftApplication;
        // Load an interstitial ad.
        interstitial.LoadAd(createAdRequest());
    }
    // Returns an ad request with custom ad targeting.
    private AdRequest createAdRequest()
    {
        return new AdRequest.Builder()
            .AddTestDevice(AdRequest.TestDeviceSimulator)
                .AddTestDevice("9ACD01B470951161A30C0AA4B6DA3A7D")
                .AddKeyword("game")
                .SetGender(Gender.Male)
                .SetBirthday(new DateTime(1982, 1, 1))
                .TagForChildDirectedTreatment(false)
                .AddExtra("color_bg", "9B30FF")
                .Build();
    }
    private void ShowInterstitial()
    {
        if (interstitial.IsLoaded())
        {
            interstitial.Show();
        }
        else
        {
            print("Interstitial is not ready yet.");
        }

removing the DontDestroyOnLoad and adding the script manually to each/some scene doesn’t change the behaviour. Tried interstitial.Destroy() at different places. Console tells me it gets destroyed but it looks like it never gets created again.

I’m completely lost, any input is welcome (please don’t suggest plugins)

You can show a requested interstitial only once. If you need to show it again, you have to request another interstitial.

2 Likes

hmm … I thought I realized that … read about that in countless other topics.
could be I got it all wrong?!

Doesnt this achieve exactly that?
interstitial.Destroy() and then RequestInterstitial()
(see commented out part in the script above)

or does “request another one” actually mean “a whole new one with a different ad-Id than the one before”?

Your code in the Update() will spamm Destroy() and Request() each frame so the commented part is wrong for testing. You just destroy it before it can load.

I’m not 100% sure what part it was exactly and where I got new information, but your last answer helped me to try some more and finally succeed! So thanks so much for helping out!

(in answer to your last input about the loading/destroying spamming. I did think about that and thought I avoided the issue by adding another PlayerPrefs.SetInt(“AdmobInt”,PlayerPrefs.GetInt(“AdmobInt”)+1); after the AdRequest.
Not sure why that didn’t help.

But for now I’m just glad for this to work.

Hi San.Daniele,

could you tell me how did you solve this problem? or maybe show the code fix it?
i have the same problem and i have been stuck for days.

i want to show a interstitial ad when the level is complete. I have one scene only.
So, i have a static bool isLevelCompleted.
When this bool is true, in another script, (Adcontroller script), inside the update, i have this condition

void update {
    if (isLevelCompleted == true) {
             isLevelCompleted = false;
             loadInterstitial ()
             ShowInterstitial()
     }
}

the app shows the interstitial Ad after complete the first level, but not the second and i don’t know why.

public void LoadInterstitialAd ()
{
    AdRequest request = new AdRequest.Builder ().Build ();

    myInterstitialAd.LoadAd (request);
}

public void ShowInterstitialAd()
{
    if (myInterstitialAd.IsLoaded ())
    {
        myInterstitialAd.Show ();
    }
}

I have a very similar problem,

My problem is this, the Admob ads are shown, but only the first time I run the game, When I exit game and run it again, ads do not show. They will show only if I clear data of the game on android device (clear cache) or if I remove and install the app again.

Note - That applies to Interstitials and video reward ads. (I didn’t test with banner because I don’t need them)

I have tested on another device and the same thing happens.

With test mode ads, It works fine.

1 Like