Interstitial Ads - cleveradssolutions/CAS-Unity Wiki

:zap: Before you start
Make sure you have correctly Initialize SDK.

Implementation by UnityEditor | Script C#


Interstitial ads are full-screen ads that cover the interface of their host app. They're typically displayed at natural transition points in the flow of an app, such as during the pause between levels in a game. When an app shows an interstitial ad, the user has the choice to either tap on the ad and continue to its destination or close it and return to the app.

This guide explains how to integrate interstitial ads into a Unity app.

Enable Interstitial Ads (Third switch) for your game in Assets > CleverAdsSolutions > Settings menu:
image

For easier ads integration using the Unity Editor, try the new InterstitialAdObject.

Load an Ad

By default, the auto-load ads mode is used and a load method does not need to be called.
If you use LoadingManagerMode.Manual then please call load before each show ad.

manager.LoadAd(AdType.Interstitial);

You can get a callback for the successful loading of the ads with using OnLoadedAd event.

Ad Availability

You can ask for the ad availability directly by calling the following function:

bool adLoaded = manager.IsReadyAd(AdType.Interstitial);

⚠️ We don’t recommend waiting for IsReadyAd to change in an Update or Coroutine. This method call the native SDK and can affect the performance of your game. Subscribe to the OnLoadedAd event instead.

Show the Ad

To display the ad, call the following method with AdType.Interstitial:

manager.ShowAd(AdType.Interstitial);

Ad events

To further customize the behavior of your ad, you can hook into a number of events in the ad's lifecycle: loading, opening, closing, and so on. Listen for these events by registering a delegate for the appropriate event, as shown below.

void OnEnable () {
    ...
    // Called when the ad is displayed.
    manager.OnInterstitialAdShown += () => Debug.Log("Interstitial shown");
    // The same call as the `OnInterstitialAdShown` but with `AdMetaData` about the impression. 
    manager.OnInterstitialAdOpening += (data) => Debug.Log("Interstitial Ad " + data.ToString());
    // Called when the ad is failed to display.
    manager.OnInterstitialAdFailedToShow += (error) => Debug.LogError(error);
    // Called when the user clicks on the Ad.
    manager.OnInterstitialAdClicked += () => Debug.Log("Interstitial clicked");
    // Called when the ad is closed.
    manager.OnInterstitialAdClosed += () => Debug.Log("Interstitial closed");
}

⭐ Read more about event OnInterstitialAdOpening with Impression Level Data and AdMetaData.

⚠️ Callbacks from CleverAdsSolutions are not guaranteed to be called on Unity thread. Read more about Execute events on Unity Thread.

Minimum interval between impressions

You can limit the posting of an interstitial ad to a period of time in seconds after the ad is closed, during which display attempts will fail. That the interval starts only after the Interstitial Ad closes OnInterstitialAdClosed.
During interval after ad closed, display attempts will fire event OnInterstitialAdFailedToShow with AdError.IntervalNotYetPassed.

Change the interstitial ad impression interval using the following method:

CAS.MobileAds.settings.interstitialInterval = interval;

If you need to wait for a period of time after the start of the game or after showing a Rewarded Ad until next Interstitial Ad impression then please call the following method:

CAS.MobileAds.settings.RestartInterstitialInterval();

⭐ We recommend define the interstitial ad impression interval once before mediation manager is initialized to be able to override the value remotely via the web interface.

Muted Ads Sounds

Sounds in Interstitial and Rewarded ads mute state. Disabled by default.

CAS.MobileAds.settings.isMutedAdSounds = mute;

Some best practices

Samples


What’s Next?