Migrate to Interstitial Ad Unit API

This guide explains how to transition to the LevelPlay Interstitial APIs (using an ad unit ID) from your current implementation, to load and display interstitial ads.

⚡ Before you start
  • The min supported SDK is 8.4.0. You can download the latest SDK here.
  • Make sure to initialize the SDK using LevelPlay Initialization API. Learn more here.
  • You can find the AdUnitID in LevelPlay dashboard. Learn more here.

Create Interstitial Ad Object

The creation of the interstitial ad object should be done after receiving OnInitSuccess callback.

// Create interstitial ad object 
interstitialAd = new LevelPlayInterstitialAd(interstitialAdUnitId);
  • Light theme
  • Dark theme
  • Copy to clipboard

Register to Interstitial Events 

Implement the LevelPlayInterstitialAdListener in your code instead of LevelPlayInterstitialListener to get informed of ad delivery. 

  • It is recommended to set the listener before loading the interstitial ad.
  • Please note that each interstitial ad should have its own listener implementation.
  • Callbacks run on the main thread.
// Register to interstitial events
interstitialAd.OnAdLoaded += InterstitialOnAdLoadedEvent;
interstitialAd.OnAdLoadFailed += InterstitialOnAdLoadFailedEvent;
interstitialAd.OnAdDisplayed += InterstitialOnAdDisplayedEvent;
interstitialAd.OnAdDisplayFailed += InterstitialOnAdDisplayFailedEvent;
interstitialAd.OnAdClicked += InterstitialOnAdClickedEvent;
interstitialAd.OnAdClosed += InterstitialOnAdClosedEvent;
interstitialAd.OnAdInfoChanged += InterstitialOnAdInfoChangedEvent;

// Implement the events
void InterstitialOnAdLoadedEvent(LevelPlayAdInfo adInfo){}
void InterstitialOnAdLoadFailedEvent(LevelPlayAdError error){}
void InterstitialOnAdDisplayedEvent(LevelPlayAdInfo adInfo){}
void InterstitialOnAdDisplayFailedEvent(LevelPlayAdDisplayInfoError infoError){}
void InterstitialOnAdClickedEvent(LevelPlayAdInfo adInfo){}
void InterstitialOnAdClosedEvent(LevelPlayAdInfo adInfo){}
void InterstitialOnAdInfoChangedEvent(LevelPlayAdInfo adInfo){}
  • Light theme
  • Dark theme
  • Copy to clipboard
Legacy Ad Unit (new)
Listener IronSourceInterstitialEvents LevelPlayInterstitialAdListener
Callbacks OnAdReady OnAdLoaded 
OnAdLoadFailed OnAdLoadFailed
OnAdOpened OnAdDisplayed
OnAdClosed OnAdClosed
OnAdShowFailed OnAdDisplayFailed
OnAdClicked OnAdClicked
OnAdShowSucceeded – (deprecated)
OnAdInfoChanged

LevelPlay Ad Info

Ad Info

The AdInfo class returned by the interstitial listener callbacks has been replaced by LevelPlayAdInfo.

Learn more about its implementation and available fields here.

Load Interstitial Ad

To load an interstitial ad, use LoadAd instead of LoadInterstitial.

// Load interstitial ad
interstitialAd.LoadAd();
  • Light theme
  • Dark theme
  • Copy to clipboard

Show Interstitial Ad

Show an interstitial ad after you receive the OnAdLoaded callback using the LevelPlayInterstitialAdListener APIs.

  • It is required to share Activity
  • If using placements, pass the placement name in the ShowAd API as shown in the Placements section below.
  • Once the ad has been successfully displayed to the user, you can load another ad by repeating the loading step. 
// Show ad without placement 
interstitialAd.ShowAd();
// Show ad with placement 
interstitialAd.ShowAd(placementName: "placementName");
  • Light theme
  • Dark theme
  • Copy to clipboard

Check Ad is Ready

To avoid show failures, and to make sure the ad could be displayed correctly, we recommend using the following API before calling the ShowAd API.

IsAdReady – returns true if ad was loaded successfully and ad unit is not capped, or false otherwise.

IsPlacementCapped – returns true when a valid placement is capped. If the placement is not valid, or not capped, this API will return false.

// Check that ad is ready and that the placement is not capped
if (interstitialAd.IsAdReady() && !LevelPlayInterstitialAd.IsPlacementCapped(placementName))
{ 
    interstitialAd.ShowAd(placementName); 
}
  • Light theme
  • Dark theme
  • Copy to clipboard

Placements

We support placements pacing and capping for interstitial on the LevelPlay dashboard. 

If placements are set up for interstitial ads, call the ShowAd method to serve the ad for a specific placement.

// Check that ad is ready and that the placement is not capped
if (interstitialAd.IsAdReady() && !LevelPlayInterstitialAd.IsPlacementCapped(placementName))
{ 
    interstitialAd.ShowAd(placementName); 
}
  • Light theme
  • Dark theme
  • Copy to clipboard

Multiple Ad Unit Interstitial APIs

Legacy Ad Unit (new)
Class IronSource LevelPlayInterstitialAd
API LoadInterstitial LoadAd
ShowInterstitial ShowAd
IsInterstitialPlacementCapped IsPlacementCapped
IsInterstitialReady IsAdReady

Full Implementation Example of Interstitial Ads

// Create interstitial object
interstitialAd = new LevelPlayInterstitialAd(interstitialAdUnitId);

// Register to interstitial events
interstitialAd.OnAdLoaded += InterstitialOnAdLoadedEvent;
interstitialAd.OnAdLoadFailed += InterstitialOnAdLoadFailedEvent;
interstitialAd.OnAdDisplayed += InterstitialOnAdDisplayedEvent;
interstitialAd.OnAdDisplayFailed += InterstitialOnAdDisplayFailedEvent;
interstitialAd.OnAdClicked += InterstitialOnAdClickedEvent;
interstitialAd.OnAdClosed += InterstitialOnAdClosedEvent;
interstitialAd.OnAdInfoChanged += InterstitialOnAdInfoChangedEvent;

void ShowInterstitialAd() {
    if (interstitialAd.IsAdReady()) { 
        interstitialAd.ShowAd(); 
    } 
} 
void ShowInterstitialAd(string placementName) {
    if (interstitialAd.IsAdReady() && !LevelPlayInterstitialAd.IsPlacementCapped(placementName)) {
        interstitialAd.ShowAd(placementName);
    }
}

#region Interstitial events
void InterstitialOnAdLoadedEvent(LevelPlayAdInfo adInfo) {}
void InterstitialOnAdLoadFailedEvent(LevelPlayAdError error) {}
void InterstitialOnAdDisplayedEvent(LevelPlayAdInfo adInfo) {}
void InterstitialOnAdDisplayFailedEvent(LevelPlayAdDisplayInfoError infoError) {}
void InterstitialOnAdClickedEvent(LevelPlayAdInfo adInfo) {}
void InterstitialOnAdClosedEvent(LevelPlayAdInfo adInfo) {}
void InterstitialOnAdInfoChangedEvent(LevelPlayAdInfo adInfo) {}
  • Light theme
  • Dark theme
  • Copy to clipboard

LevelPlay Mediation Demo App

The Integration Demo application demonstrates how to integrate interstitial Ad Unit APIs in your app.

Download Android Demo Application

Done!

You are now all set up to serve interstitial ads in your application using our new Multiple Ad Unit APIs.