Interstitial Integration for Unity Plugin
The Unity LevelPlay Interstitial is a full-screen ad unit, usually served at natural transition points during the app lifecycle.
- Make sure that you have correctly integrated the ironSource SDK into your application. Integration is outlined here.
- Make sure to initialize the SDK using LevelPlay Initialization API.
- You can find the AdUnitID in LevelPlay dashboard. Learn more here.
- This documentation is relevant for SDK 8.4.0+. Documentation for legacy interstitial APIs (SDK 8.4.0 and below) can be found 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);
Register to Interstitial Events
Implement the LevelPlayInterstitialAdListener in your code 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){}
LevelPlay Ad Info
The LevelPlayAdInfo parameter includes information about the loaded ad.
Learn more about its implementation and available fields here.
Load Interstitial Ad
To load an interstitial ad use LoadAd.
// Load interstitial ad
interstitialAd.LoadAd();
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");
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);
}
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);
}
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) {}
LevelPlay Mediation Demo App
The Integration Demo application demonstrates how to integrate interstitial Ad Unit APIs in your app.
Download Unity Demo Application
Done!
You are now all set up to serve banners in your application. Verify your integration with our Integration Test Suite.
Follow our integration guides to integrate additional Interstitial Ad networks or configure additional ad formats: