Interstitial Integration for Flutter

The ironSource Interstitial is a full-screen ad unit, usually served at natural transition points during the app lifecycle. We support both static and video interstitials. You can also serve interstitials through the ironSource Mediation platform.

Before you start
  • Make sure that you have correctly integrated the Flutter Plugin into your app. Integration is outlined here.
  • Make sure to initalize the SDK using LevelPlay Initalization 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 and Register to Events

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

The ironSource SDK fires several events to inform you of your Interstitial activity. To receive these events, register the listeners of the ad unit.
Make sure you set the listeners before initializing the SDK to prevent any loss of information.

LevelPlayInterstitialAd? _interstitialAd; 
@override 
void initState() { 
	super.initState(); 
	_createInterstitialAd(); 
}
 
void _createInterstitialAd() {
	_interstitialAd = LevelPlayInterstitialAd(adUnitId: [YOUR_AD_UNIT]);
	_interstitialAd!.setListener([YOUR_LISTENER]); 
}

Set Interstitial Listener

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.
  @override
  void onAdLoaded(LevelPlayAdInfo adInfo) {
    // Provided when the ad is successfully loaded
  }
  @override
  void onAdLoadFailed(LevelPlayAdError error) {
    // Provided when the ad fails to load. Ad Unit information is included
  }
  @override
  void onAdDisplayed(LevelPlayAdInfo adInfo) {
    // Provided when the ad is displayed. This is equivalent to an impression
  }
  @override
  void onAdDisplayFailed(LevelPlayAdError error, LevelPlayAdInfo adInfo) {
    // Provided when the ad fails to be displayed
  }
  
  @override
  void onAdClicked(LevelPlayAdInfo adInfo) {
    // Provided when the user clicks on the ad
  }
  @override
  void onAdClosed(LevelPlayAdInfo adInfo) {
    // Provided when the ad is closed
  }
  @override
  void onAdInfoChanged(LevelPlayAdInfo adInfo) {
    // Provided when the ad info is updated. Available when another ad has loaded, and includes a higher CPM/Rate
  }

Load Interstitial Ad

To load an interstitial ad use loadAd.

_interstitialAd?.loadAd();

Show Interstitial Ad

Show an interstitial ad after you receive the onAdLoaded callback, using showAd.

  • 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(placement: [YOUR_PLACEMENT]);

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(_interstitial?.isAdReady() && !LevelPlayInterstitialAd.isPlacementCapped([YOUR_PLACEMENT])) { 
    _interstitial!.showAd(placement:[YOUR_PLACEMENT]); 
}

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(_interstitial?.isAdReady() && !LevelPlayInterstitialAd.isPlacementCapped([YOUR_PLACEMENT])) { 
    _interstitial!.showAd(placement:[YOUR_PLACEMENT]); 
}

Done!

You can now deliver ironSource Interstitial Ads on your app.