Interstitial integration for React Native

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 React Native Plugin into your app. You can access the integration guidance outlined here.

Step 1. Implement the Listeners

The ironSource SDK fires several events to inform you of your Interstitial activity. To receive these events, register the listeners of the ad unit.

Import the following event class from the IronSource mediation:

import {
  LevelPlayInterstitialEvents,
  IronSource,
  IronSourceError,
  IronSourceAdInfo,
} from 'ironsource-mediation'

The SDK will notify you of all possible events listed below:

/**
 * Invoked when an Interstitial ad became ready to be shown as a result of the precedent load function call.
 */
LevelPlayInterstitialEvents.onAdReady.setListener((adInfo: IronSourceAdInfo) => {});
/**
 * Invoked when there is no Interstitial ad available as a result of the precedent loadInterstitial call.
 * You can learn about the reason by examining the error.
 */
LevelPlayInterstitialEvents.onAdLoadFailed.setListener((error: IronSourceError) => {});
/**
 * Invoked when an Interstitial ad has opened.
 */
LevelPlayInterstitialEvents.onAdOpened.setListener((adInfo: IronSourceAdInfo) => {});
/**
 * Invoked when the ad is closed and the user is about to return to the application.
 */
LevelPlayInterstitialEvents.onAdClosed.setListener((adInfo: IronSourceAdInfo) => {}); 
/**
 * Invoked when an Interstitial ad failed to show.
 * You can learn about the reason by examining the error.
 */
LevelPlayInterstitialEvents.onAdShowFailed.setListener((ironSourceError: IronSourceError, adInfo: IronSourceAdInfo) => {});
/**
 * Invoked when the end user clicked on the interstitial ad.
 * - NOTE - This event is not supported by all the networks.
 */
LevelPlayInterstitialEvents.onAdClicked.setListener((adInfo: IronSourceAdInfo) => {});
/**
 * 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 onAdOpened.
 */
LevelPlayInterstitialEvents.onAdShowSucceeded.setListener((adInfo: IronSourceAdInfo) => {});
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 event 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.

LevelPlayInterstitialEvents.onAdReady.setListener((adInfo: IronSourceAdInfo) => {});

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

isInterstitialReady(): Promise<boolean>

We don’t recommend making consecutive requests for an interstitial ad in a short time span. 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.

showInterstitial(placementName?: string) => Promise<void>

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:

isInterstitialPlacementCapped(placementName: string): Promise<boolean>
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!