Skip to main content
Version: 6.x.x

Interstitial Ads

Overview

Interstitial ads are full-screen ad units that are triggered at natural transition points within the app workflow, such as between levels or during screen transitions. BlueStack Interstitial ads support multiple creative formats, including static assets (images or text) and rich media (e.g., video or interactive content).

Before You Start. Make sure that you have correctly integrated the BlueStack React Native Plugin into your application. Integration is outlined here.

For a working implementation of this ad format, see the azerion-inapp-demo-reactnative demo app.

Create an Interstitial Ad

You need to import the InterstitialAdManager component in order to display BlueStack interstitial ads.

import { InterstitialAdManager } from "@azerion/bluestack-sdk-react-native";

Load an Interstitial Ad

You can load an interstitial ad right after the SDK finishes its initialization. You have to pass the platform specific interstitial placement id to the loadAd method.

Without AdPreference

InterstitialAdManager.loadAd("/" + appId + "/interstitial", false);

With AdPreference

To request an interstitial ad using AdPreference, provide an instance of AdPreference in the loadAd method:

/**
* Load interstitial ad.
* @param: placementId
* @param: autoDisplay: chooses if the interstitial will be displayed automatically (optional)
* @param: preference (optional)
*/
InterstitialAdManager.loadAd("/" + appId + "/interstitial", false, preference);

Ad events

Register for Interstitial events

InterstitialAdManager exposes the following events through its lifecycle. Register for interstitial ad events before loading the interstitial ad.

EventsDefinition
onAdLoadedAd is successfully loaded and SDK is ready to display the ad.
onAdFailedErrorThe ad failed to load or display.
onAdClickedUser has clicked the ad. Ad may open a link in browser.
onAdDisplayedAd has appeared on the screen.
onAdDismissedThe ad has disappeared.

Implement Interstitial events

Here's an example of how to register event listeners for interstitial ads:

InterstitialAdManager.addEventListener((event) => {
switch (event.interstitialEvent) {
case "onAdLoaded":
console.log("Interstitial Ad Loaded");
break;
case "onAdDismissed":
console.log("Interstitial Ad disappeared");
break;
case "onAdDisplayed":
console.log("Interstitial Ad displayed");
break;
case "onAdClicked":
console.log("Interstitial Ad did click");
break;
case "onAdFailedError":
console.log("Interstitial Ad failed:" + event.errorBluestackMessage);
break;
default:
break;
}
});

Here's an example of how to remove all event listeners:

InterstitialAdManager.removeAllEventListeners();
caution

Make sure you only register the event listener once.

Show an Interstitial Ad

After loading the interstitial ad you can request it to be displayed using the displayAd method.

info

Listen to interstitial ad events to make sure the ad was successfully loaded before you call the displayAd method.

InterstitialAdManager.displayAd();