Search code examples
unity-game-engineadmobinterstitial

Unity Admob Interstitial Ads Not Showing


I know this question has been asked several times but i got stuck even though i have implemented and tried all the solutions. I follow this tutorial for interstitial ads showing:

https://developers.google.com/admob/unity/interstitial

My main goal is to show ad whenever user taps on "Restart" button for the game.

Here is my main ad manager class (which is linked with an game object):

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;

public class AdManager : MonoBehaviour {

    public string interstitial_id;
    public string app_id;
    public InterstitialAd interstitial;

    // Use this for initialization
    void Start () {
        //MobileAds.Initialize(app_id);
        DontDestroyOnLoad(this);
        Prepare_Video();
        Debug.Log("Admob ilklendirildi: " + interstitial.ToString());
    }


    public void Show_Video()
    {
        Debug.Log("Reklam hazırlık durumu: " + interstitial.IsLoaded());
        if (interstitial.IsLoaded()) {
            Debug.Log("Reklam hazır, gösterilecek");
            interstitial.Show();
        }
        else
        {
            Prepare_Video();
            interstitial.Show();
        }
    }

    public void Destroy_Video()
    {
        if(interstitial != null)
        {
            interstitial.Destroy();
        }
    }

    public void Prepare_Video()
    {
        interstitial = new InterstitialAd(interstitial_id);
        AdRequest request = new AdRequest.Builder().Build();
        interstitial.LoadAd(request);
    }

}

I call the show method in restart action:

  public void RestartScene()
    {
        GameStatusText.gameObject.SetActive(false);
        RestartButton.gameObject.SetActive(false);
        MeterText.gameObject.SetActive(false);
        MeterTextTop.text = "";
        Time.timeScale = 1;
        TimeController.TimeLeft = 50f;
        FindObjectOfType<AdManager>().Show_Video();
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    }

Solution

  • I have reinstalled the admob plugin and followed the instructions from the beginning. It worked. It seems like my plugin package was damaged and some files were missing.