Skip to main content
Version: 6.x.x

Interstitial Ad

Integration​

Step 1. Instantiate Interstitial Ad​

You can instantiate an InterstitialAd right after the SDK finishes initialization. Pass the platform-specific interstitial placement id to the InterstitialAd constructor.

public class BlueStackAdsController : MonoBehaviour
{
private InterstitialAd _interstitialAd;

void Start()
{
BlueStackAds.SetDebugMode(true);
BlueStackAds.Initialize("app_id", HandleInitCompleteAction);
}

private void HandleInitCompleteAction(InitializationStatus status)
{
_interstitialAd = new InterstitialAd(placementId);
}
}

Step 2. Register event listeners​

InterstitialAd exposes the following events through its lifecycle.

EventPayloadDefinition
OnAdLoadedEventArgsAd finished loading and is ready to be shown.
OnAdFailedToLoadBlueStackErrorThe ad failed to load.
OnAdDisplayedEventArgsThe ad has appeared on screen.
OnAdFailedToDisplayBlueStackErrorThe ad failed to display after Show() was called.
OnAdClickedEventArgsThe user clicked the ad.
OnAdDismissedEventArgsThe user dismissed the full-screen ad. This is terminal — the instance cannot be re-shown.
_interstitialAd.OnAdLoaded += (sender, args) =>
{
Debug.Log("OnAdLoaded");
};

_interstitialAd.OnAdFailedToLoad += (sender, error) =>
{
Debug.LogError("OnAdFailedToLoad: " + error.Message);
};

_interstitialAd.OnAdDisplayed += (sender, args) =>
{
Debug.Log("OnAdDisplayed");
};

_interstitialAd.OnAdFailedToDisplay += (sender, error) =>
{
Debug.LogError("OnAdFailedToDisplay: " + error.Message);
};

_interstitialAd.OnAdClicked += (sender, args) =>
{
Debug.Log("OnAdClicked");
};

_interstitialAd.OnAdDismissed += (sender, args) =>
{
Debug.Log("OnAdDismissed");
};
caution

Make sure you only register event listeners once.

Step 3. Load Interstitial ad​

InterstitialAd exposes two Load overloads; one parameterless, and one taking a RequestOptions instance for audience targeting.

  • Without targeting
_interstitialAd.Load();
  • With targeting
var requestOptions = new RequestOptions(
age: 25,
gender: Gender.Male,
location: new Location(35.757866, 10.810547, Location.GPS_PROVIDER),
consentFlag: 1,
language: "en",
keyword: "brand=myBrand;category=sport",
contentUrl: "https://console.bluestack.app");

_interstitialAd.Load(requestOptions);

RequestOptions is immutable and reusable across Load calls. See Targeting Audiences for the full field reference and consent-flag semantics.

Step 4. Display Interstitial ad​

After the ad has loaded, request it to be displayed. Check IsReady to confirm the ad is loaded before calling Show().

if (_interstitialAd.IsReady)
{
_interstitialAd.Show();
}

Equivalently, gate on OnAdLoaded:

_interstitialAd.OnAdLoaded += (sender, args) =>
{
_interstitialAd.Show();
};

Destroy interstitial ad​

Destroy the interstitial before creating a new one.

_interstitialAd.Destroy();