Interstitial - Atmosplay/AtmosplayAds-Unity GitHub Wiki

Create an Interstitial Ad

using System;
using UnityEngine;
using AtmosplayAds.Api;
using AtmosplayAds.Common;
public class AtmosplayAdsDemoScript : MonoBehaviour
{
#if UNITY_Android
  const string AtmosplayAds_App_ID_Interstitial = "Your_AtmosplayAds_App_ID_Interstitial_Android";
  const string AtmosplayAds_AdUnit_ID_Interstitial = "Your_AtmosplayAds_AdUnit_ID_Interstitial_Android";
#elif UNITY_IOS
  const string AtmosplayAds_App_ID_Interstitial = "Your_AtmosplayAds_App_ID_Interstitial_iOS";
  const string AtmosplayAds_AdUnit_ID_Interstitial = "Your_AtmosplayAds_AdUnit_ID_Interstitial_iOS";
#else
  const string AtmosplayAds_App_ID_Interstitial = "unexpected_platform";
  const string AtmosplayAds_AdUnit_ID_Interstitial = "unexpected_platform";
#endif

  InterstitialAd interstitial;

  void Start() 
  {
    AdOptions adOptions = new AdOptionsBuilder()
      .SetChannelId("")
      .SetAutoLoadNext(true)
      .build();

    interstitial = new InterstitialAd(AtmosplayAds_App_ID_Interstitial, AtmosplayAds_AdUnit_ID_Interstitial, adOptions);
    interstitial.OnAdLoaded += HandleInterstitialLoaded;
    interstitial.OnAdFailedToLoad += HandleInterstitialFailedToLoad;
    interstitial.OnAdStarted += HandleInterstitialStart;
    interstitial.OnAdClicked += HandleInterstitialClicked;
    interstitial.OnAdClosed += HandleInterstitialClosed;
  }
  
  #region Interstitial callback handlers
  public void HandleInterstitialLoaded(object sender, EventArgs args)
  {
    print("===> HandleInterstitialLoaded event received");
  }
  public void HandleInterstitialFailedToLoad(object sender, AdFailedEventArgs args)
  {
    print("===> HandleInterstitialFailedToLoad event received with message: " + args.Message);
  }
  public void HandleInterstitialStart(object sender, EventArgs args)
  {
    print("===> HandleInterstitialStart event received.");
  }
  public void HandleInterstitialClicked(object sender, EventArgs args)
  {
    print("===> HandleInterstitialClicked event received.");
  }
  public void HandleInterstitialClosed(object sender, EventArgs args)
  {
    print("===> HandleInterstitialClosed event received.");
  }
  #endregion
}

Request Interstitial

interstitial.LoadAd(AtmosplayAds_AdUnit_ID_Interstitial);

Determine If Interstitial Has Been Loaded

interstitial.IsReady(AtmosplayAds_AdUnit_ID_Interstitial)

Present Interstitial

if(interstitial.IsReady(AtmosplayAds_AdUnit_ID_Interstitial))
{
  interstitial.Show(AtmosplayAds_AdUnit_ID_Interstitial);
}