The Unity LevelPlay Interstitial is a full-screen ad unit, usually served at natural transition points during the app lifecycle.
Prerequisites
- Ensure that you have correctly integrated the ironSource SDK into your application. Integration is outlined here.
- Ensure that you initialize the SDK using LevelPlay Initialization API.
- Find the AdUnitID in LevelPlay dashboard.
Create Interstitial Ad Object
The creation of the interstitial ad object must be performed after receiving the OnInitSuccess callback.
The object is a reusable instance that can handle multiple loads and shows throughout the session. After creation, it should be used to load and show ads for the same ad unit.
For more advanced implementations, you may create multiple interstitial ad objects if necessary.
// 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.
- 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.
- If using placements, pass the placement name in the ShowAd API as shown in the Placements section below.
- After 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
public class InterstitialAdSample { private LevelPlayInterstitialAd interstitialAd void CreateInterstitialAd() { //Create InterstitialAd instance interstitialAd= new LevelPlayInterstitialAd("interstitialAdUnitId"); //Subscribe InterstitialAd events interstitialAd.OnAdLoaded += InterstitialOnAdLoadedEvent; interstitialAd.OnAdLoadFailed += InterstitialOnAdLoadFailedEvent; interstitialAd.OnAdDisplayed += InterstitialOnAdDisplayedEvent; interstitialAd.OnAdDisplayFailed += InterstitialOnAdDisplayFailedEvent; interstitialAd.OnAdClicked += InterstitialOnAdClickedEvent; interstitialAd.OnAdClosed += InterstitialOnAdClosedEvent; interstitialAd.OnAdInfoChanged += InterstitialOnAdInfoChangedEvent; } void LoadInterstitialAd() { //Load or reload InterstitialAd interstitialAd.LoadAd(); } void ShowInterstitialAd() { //Show InterstitialAd, check if the ad is ready before showing if (interstitialAd.IsAdReady()) { interstitialAd.ShowAd(); } } //Implement InterstitialAd events void InterstitialOnAdLoadedEvent(LevelPlayAdInfo adInfo) { } void InterstitialOnAdLoadFailedEvent(LevelPlayAdError ironSourceError) { } void InterstitialOnAdClickedEvent(LevelPlayAdInfo adInfo) { } void InterstitialOnAdDisplayedEvent(LevelPlayAdInfo adInfo) { } void InterstitialOnAdDisplayFailedEvent(LevelPlayAdDisplayInfoError adInfoError) { } 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
Verify your integration with our Integration Test Suite.
Next steps
Follow our integration guides to integrate additional Interstitial Ad networks or configure additional ad formats: