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 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.setISListener(mInterstitialListener);

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

class YourDartClass with IronSourceInterstitialListener {
  /// Invoked when an Interstitial ad became ready to be shown as a result of the precedent load function call.
  @override
  void onInterstitialAdReady() {}
  /// Invoked when there is no Interstitial ad available as a result of the precedent [loadInterstitial] call.
  /// - You can learn about the reason by examining [error]
  @override
  void onInterstitialAdLoadFailed(IronSourceError error) {}
  /// Invoked when an Interstitial ad has opened
  @override
  void onInterstitialAdOpened() {}
  /// Invoked when the ad is closed and the user is about to return to the application.
  @override
  void onInterstitialAdClosed() {}
  /// Invoked when an Interstitial ad failed to show.
  /// - You can learn about the reason by examining [error]
  @override
  void onInterstitialAdShowFailed(IronSourceError error) {}
  /// Invoked when the end user clicked on the interstitial ad.
  /// - NOTE - This event is not supported by all the networks.
  @override
  void onInterstitialAdClicked() {}
  /// Invoked when an Interstitial screen is about to open.
  /// - NOTE - This event is not supported by all the networks.
  /// - You should NOT treat this event as an interstitial impression,
  /// but rather use [onInterstitialAdOpened].
  @override 
  void onInterstitialAdShowSucceeded() {}
}
Note:
  • The onInterstitialAdOpened() and onInterstitialAdShowSucceeded() 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 onInterstitialAdClosed 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 onInterstitialAdReady callback when an ad is loaded and ready to be shown to your user.

public void onInterstitialReady(){}

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 onInterstitialAdReady 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!