Interstitial Integration for Flutter Legacy pre v8.4.0

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 you’ve integrated the ironSource Flutter Plugin into your app. You can access integration guidance is outlined here.

Step 1. Implement the Listener

The ironSource SDK fires several events to inform you of yourInterstitial 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.

IronSource.setLevelPlayInterstitialListener(mLevelPlayInterstitialListener);

The SDK will notify your delegate of all possible events listed below:

abstract class LevelPlayInterstitialListener {
 /// Indicates that the interstitial ad was loaded successfully.
 /// - [adInfo] includes information about the loaded ad.
 ///
 /// Native SDK Reference
 /// - Android: onAdReady
 /// -     iOS: didLoadWithAdInfo
 void onAdReady(IronSourceAdInfo adInfo);
 /// Indicates that the ad failed to be loaded
 ///
 /// Native SDK Reference
 /// - Android: onAdLoadFailed
 /// -     iOS: didFailToLoadWithError
 void onAdLoadFailed(IronSourceError error);
 /// Invoked when the Interstitial Ad Unit has opened, and user left the application screen.
 /// - This is the impression indication.
 ///
 /// Native SDK Reference
 /// - Android: onAdOpened
 /// -     iOS: didOpenWithAdInfo
 void onAdOpened(IronSourceAdInfo adInfo);
 /// Invoked when the interstitial ad closed and the user went back to the application screen.
 ///
 /// Native SDK Reference
 /// - Android: onAdClosed
 /// -     iOS: didCloseWithAdInfo
 void onAdClosed(IronSourceAdInfo adInfo);
 /// The interstitial ad failed to show.
 ///
 /// Native SDK Reference
 /// - Android: onAdShowFailed
 /// -     iOS: didFailToShowWithError
 void onAdShowFailed(IronSourceError error, IronSourceAdInfo adInfo);
 /// Invoked when end user clicked on the interstitial ad
 ///
 /// Native SDK Reference
 /// - Android: onAdClicked
 /// -     iOS: didClickWithAdInfo
 void onAdClicked(IronSourceAdInfo adInfo);
   /// Invoked before the interstitial ad was opened, and before the InterstitialOnAdOpenedEvent is reported.
 /// This callback is not supported by all networks, and we recommend using it only if
 /// it's supported by all networks you included in your build.
 ///
 /// Native SDK Reference
 /// - Android: onAdShowSucceeded
 /// -     iOS: didShowWithAdInfo
 void onAdShowSucceeded(IronSourceAdInfo adInfo);
}
Note:
  • The onAdOpened() and onAdShowSucceeded() events convey that the ad format has taken over the app screen and been displayed but does not indicate that an ad has been successfully served to your end-user.
  • Do not assume the callbacks are always running on the main thread. Any UI interaction or updates resulting from ironSource callbacks need to be passed to the main thread before executing.
  • Please make sure to set the listeners before SDK initialization. This will ensure the SDK sends all relevant information. 

Step 2. Load Interstitial Ad

We recommend requesting an Interstitial Ad a short while before you plan on showing it to your users as the loading process can take time.
To request an interstitial ad, call the following method:

IronSource.loadInterstitial();

Note:  If you’d like to serve several Interstitial Ads in your application, you must repeat this step after you’ve shown and closed the previous Interstitial Ad. Once the onAdClosed function is fired, you will be able to load a new Interstitial ad.

Step 3. Check Ad Availability

After you call the loadInterstitial function in Step 2, you will receive the ad availability through the listener with the onAdReady callback when an ad is loaded and ready to be shown to your user.

public void onAdReady(){} 

In addition, you can also ask for the ad availability directly by calling the following function:

Future<bool> isInterstitialReady();

We don’t recommend making consecutive requests for an interstitial ad in a short timespan. Numerous requests in a short period of time have no added value as the chance of available inventory at this time is unlikely.

Step 4. Show Interstitial Ad

Once you receive the onAdReady callback, you are ready to show an Interstitial Ad to your users. To provide the best experience for your users, make sure to pause any game action, including audio, during the time the ad is displayed.

Invoke the following method to serve an Interstitial ad to your users:

IronSource.showInterstitial(placementName);

With ironSource’s Ad Placements, you can customize and optimize the Interstitial experience. This tool enables you to present Interstitial ads to your users in different places, i.e. app launch, between levels, etc. You can use the function below to define the exact placement to show an ad. Navigate to the Ad Placement document for more details.

Future<void> showInterstitial({String? placementName});


In addition to ironSource’s Ad Placements, you can now configure capping and pacing settings for selected placements. Capping and pacing improve the user experience in your app by limiting the number of ads served within a defined timeframe. Read more about capping and pacing
here.

We recommend calling the following function to verify if a placement is capped before you serve the Interstitial to your user:

Future<bool> isInterstitialPlacementCapped({required String placementName});


Once you’ve successfully completed step 4, you will have shown your user an Interstitial Ad. In the case you want to serve another Interstitial ad, you must repeat Step 3 to request an additional Interstitial.

Done!

You can now deliver ironSource Interstitial Ads on your app!