interstitial-integration-react-native-legacy-pre840

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.

Set the LevelPlayInterstitialListener

IronSource.setLevelPlayInterstitialListener([YOUR_LISTENER])

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

 /**
     * Indicates that the interstitial ad was loaded successfully.
     * [adInfo] includes information about the loaded ad
     * 
     * Android: onAdReady
     *     iOS: didLoadWithAdInfo
     */
    onAdReady?: (adInfo: IronSourceAdInfo) => void;
    /**
     * Indicates that the ad failed to be loaded
     * [error] includes information about the error
     * 
     * Android: onAdLoadFailed
     *     iOS: didFailToLoadWithError
     */
    onAdLoadFailed?: (error: IronSourceError) => void;
    /**
     * Invoked when the Interstitial Ad Unit has opened, and user left the application screen.
     * This is the impression indication.
     * [adInfo] includes information about the loaded ad
     * 
     * Android: onAdOpened
     *     iOS: didOpenWithAdInfo
     */
    onAdOpened?: (adInfo: IronSourceAdInfo) => void;
    /**
     * Invoked when the interstitial ad closed and the user went back to the application screen.
     * [adInfo] includes information about the loaded ad
     * 
     * Android: onAdClosed
     *     iOS: didCloseWithAdInfo
     */
    onAdClosed?: (adInfo: IronSourceAdInfo) => void;
    /**
     * The interstitial ad failed to show.
     * [error] includes information about the error
     * [adInfo] includes information about the loaded ad
     * 
     * Android: onAdShowFailed
     *     iOS: didFailToShowWithError
     */
    onAdShowFailed?: (error: IronSourceError, adInfo: IronSourceAdInfo) => void; 
    /**
     * Invoked when end user clicked on the interstitial ad
     * [adInfo] includes information about the loaded ad
     * 
     * Android: onAdClicked
     *     iOS: didClickWithAdInfo
     */
    onAdClicked?: (adInfo: IronSourceAdInfo) => void;
    /**
     * 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.
     * [adInfo] includes information about the loaded ad
     * 
     * Android: onAdShowSucceeded
     *     iOS: didShowWithAdInfo
     */
    onAdShowSucceeded?: (adInfo: IronSourceAdInfo) => void;
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.

onAdReady: (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!