Interstitial code

HellO! I have reading the Interstitial Integration for Unity Plugin - IronSource Knowledge Center tutorial but I think it’s not clear how to load an interstitial. I have already get to add the banner with this code.

IronSource.Agent.loadBanner(IronSourceBannerSize.BANNER, IronSourceBannerPosition.BOTTOM);

But when I tried to follow the tutorial for interstitial is not quite clear how to call it. i just want to call interstitial when GameOver, as in other forum I called like this in mediation:

public class Game : MonoBehaviour
{  private InterstitialAds interstitialAds; }
void Awake ()
    {  interstitialAds = GetComponent<InterstitialAds>();  }
public void GameOver()
    {   interstitialAds.ShowInterstitial();  }

How do i call it in levelplay?

Any ideas in this?

For the LevelPlay interstitial, following that doc, you can relace that GameOver() function with:

void Awake ()
{ IronSource.Agent.loadInterstitial();  } // Step 2
public void GameOver() {
    if (IronSource.Agent.isInterstitialReady()) { // Step 3
        IronSource.Agent.showInterstitial(); // Step 4
    }
}

Ok, it’s really frustrating about can’t preview on editor. A lots of builds and don’t get the code working OnGameOver. So I decided to make a sample scene and added same code as the tutorial and works fine. But when I remove LoadInterstitial Button and replace it with an OnAwake, it doesn’t show up! Is anything wrong with code? Help? :frowning:

  void OnEnable()
    {
        IronSourceEvents.onSdkInitializationCompletedEvent += SdkInitializationCompletedEvent;
        IronSourceEvents.onInterstitialAdReadyEvent += InterstitialAdReadyEvent;
        IronSourceEvents.onInterstitialAdLoadFailedEvent += InterstitialAdLoadFailedEvent;
        IronSourceEvents.onInterstitialAdShowSucceededEvent += InterstitialAdShowSucceededEvent;
        IronSourceEvents.onInterstitialAdShowFailedEvent += InterstitialAdShowFailedEvent;
        IronSourceEvents.onInterstitialAdClickedEvent += InterstitialAdClickedEvent;
        IronSourceEvents.onInterstitialAdOpenedEvent += InterstitialAdOpenedEvent;
        IronSourceEvents.onInterstitialAdClosedEvent += InterstitialAdClosedEvent;
    }

    void Awake()
    {     
        IronSource.Agent.loadInterstitial();
        Debug.Log("Ad Loaded");
    }

    public void ShowInterstitial()
    {
        if (IronSource.Agent.isInterstitialReady())
        {
            IronSource.Agent.showInterstitial();
        }
    }


    void SdkInitializationCompletedEvent()
    {
        Debug.Log("unity-script: I got SdkInitializationCompletedEvent");
    }

    void InterstitialAdReadyEvent()
    {
        Debug.Log("unity-script: I got InterstitialAdReadyEvent");
    }

    void InterstitialAdLoadFailedEvent(IronSourceError error)
    {
        Debug.Log("unity-script: I got InterstitialAdLoadFailedEvent, code: " + error.getCode() + ", description : " + error.getDescription());
    }

    void InterstitialAdShowSucceededEvent()
    {
        Debug.Log("unity-script: I got InterstitialAdShowSucceededEvent");
    }

    void InterstitialAdShowFailedEvent(IronSourceError error)
    {
        Debug.Log("unity-script: I got InterstitialAdShowFailedEvent, code :  " + error.getCode() + ", description : " + error.getDescription());
    }

    void InterstitialAdClickedEvent()
    {
        Debug.Log("unity-script: I got InterstitialAdClickedEvent");
    }

    void InterstitialAdOpenedEvent()
    {
        Debug.Log("unity-script: I got InterstitialAdOpenedEvent");
    }

    void InterstitialAdClosedEvent()
    {
        Debug.Log("unity-script: I got InterstitialAdClosedEvent");
    }

I suppose should initialize before load?

IronSource.Agent.init(gameId);

It works! Finally, thanks a lot!!! :):):slight_smile: