Interstitial
Interstitial ads are full-screen advertisements. In Appodeal, they are divided into two types - static interstitial and video interstitial.
These types of ads are requested simultaneously during caching. If both of them filled an ad, the most expensive of the two will be shown.
Static interstitial - static full-screen banners.
Video interstitial - these are videos that the user can usually close 5 seconds after the start of viewing.
You can use our demo app as a reference project.
Demo App (Beta)
Check If Ad Is Loaded
You can check whether or not an ad is loaded at a certain moment. This method returns a boolean value, representing the interstitial ad loading status.
- UPM Distribution
- Manual Distribution
Appodeal.IsLoaded(AppodealAdType.Interstitial);
Appodeal.isLoaded(Appodeal.INTERSTITIAL);
We recommend you always check whether an ad is available before trying to show it.
Example:
- UPM Distribution
- Manual Distribution
if(Appodeal.IsLoaded(AppodealAdType.Interstitial)) {
Appodeal.Show(AppodealShowStyle.Interstitial);
}
if(Appodeal.isLoaded(Appodeal.INTERSTITIAL)) {
Appodeal.show(Appodeal.INTERSTITIAL);
}
Display
To show an interstitial ad, you need to call the following method:
- UPM Distribution
- Manual Distribution
Appodeal.Show(AppodealShowStyle.Interstitial);
Appodeal.show(Appodeal.INTERSTITIAL);
Manual Caching
If you need more control of interstitial ads loading use manual caching. Manual caching for Interstitial can be useful to improve display rate or decrease SDK loads when several ad types are cached.
- To disable automatic caching for interstitials, use the code below before the SDK initialization:
- UPM Distribution
- Manual Distribution
Appodeal.SetAutoCache(AppodealAdType.Interstitial, false);
Appodeal.setAutoCache(Appodeal.INTERSTITIAL, false);
- To cache Interstitial ad manually use the following method:
- UPM Distribution
- Manual Distribution
Appodeal.Cache(AppodealAdType.Interstitial);
Appodeal.cache(Appodeal.INTERSTITIAL);
Callbacks
The callbacks are used to track different events in the lifecycle of an ad, e.g. when an ad was clicked on or closed. Follow the steps below to implement them:
- UPM Distribution
- Manual Distribution
Subscribe to the desired interstitial event using one of the options from this guide. (you can subscribe to any number of events you want)
AppodealCallbacks.Interstitial.OnLoaded += (sender, args) => { };
You will find all existing interstitial events in the example below:
public void SomeMethod()
{
AppodealCallbacks.Interstitial.OnLoaded += OnInterstitialLoaded;
AppodealCallbacks.Interstitial.OnFailedToLoad += OnInterstitialFailedToLoad;
AppodealCallbacks.Interstitial.OnShown += OnInterstitialShown;
AppodealCallbacks.Interstitial.OnShowFailed += OnInterstitialShowFailed;
AppodealCallbacks.Interstitial.OnClosed += OnInterstitialClosed;
AppodealCallbacks.Interstitial.OnClicked += OnInterstitialClicked;
AppodealCallbacks.Interstitial.OnExpired += OnInterstitialExpired;
}
#region InterstitialAd Callbacks
// Called when interstitial was loaded (precache flag shows if the loaded ad is precache)
private void OnInterstitialLoaded(object sender, AdLoadedEventArgs e)
{
Debug.Log("Interstitial loaded");
}
// Called when interstitial failed to load
private void OnInterstitialFailedToLoad(object sender, EventArgs e)
{
Debug.Log("Interstitial failed to load");
}
// Called when interstitial was loaded, but cannot be shown (internal network errors, placement settings, etc.)
private void OnInterstitialShowFailed(object sender, EventArgs e)
{
Debug.Log("Interstitial show failed");
}
// Called when interstitial is shown
private void OnInterstitialShown(object sender, EventArgs e)
{
Debug.Log("Interstitial shown");
}
// Called when interstitial is closed
private void OnInterstitialClosed(object sender, EventArgs e)
{
Debug.Log("Interstitial closed");
}
// Called when interstitial is clicked
private void OnInterstitialClicked(object sender, EventArgs e)
{
Debug.Log("Interstitial clicked");
}
// Called when interstitial is expired and can not be shown
private void OnInterstitialExpired(object sender, EventArgs e)
{
Debug.Log("Interstitial expired");
}
#endregion
- Extend your class with
IInterstitialAdListener
interface:
class SomeClassName : IInterstitialAdListener {}
- Implement all required callback methods:
#region Interstitial callback handlers
// Called when interstitial was loaded (precache flag shows if the loaded ad is precache)
public void onInterstitialLoaded(bool isPrecache)
{
Debug.Log("Interstitial loaded");
}
// Called when interstitial failed to load
public void onInterstitialFailedToLoad()
{
Debug.Log("Interstitial failed to load");
}
// Called when interstitial was loaded, but cannot be shown (internal network errors, placement settings, etc.)
public void onInterstitialShowFailed()
{
Debug.Log("Interstitial show failed");
}
// Called when interstitial is shown
public void onInterstitialShown()
{
Debug.Log("Interstitial shown");
}
// Called when interstitial is closed
public void onInterstitialClosed()
{
Debug.Log("Interstitial closed");
}
// Called when interstitial is clicked
public void onInterstitialClicked()
{
Debug.Log("Interstitial clicked");
}
// Called when interstitial is expired and can not be shown
public void onInterstitialExpired()
{
Debug.Log("Interstitial expired");
}
#endregion
- Call the following method:
Appodeal.setInterstitialCallbacks(this);
All callbacks are called on native main threads that do not match the main thread of the Unity. If you need to receive callbacks in the main Unity thread follow our Callback Usage Guide.
Placements
Appodeal SDK allows you to tag each impression with different placement. To use placements, you need to create placements in Appodeal Dashboard. Read more about placements.
To show an ad with placement, you have to call show method with specifying placement's name:
- UPM Distribution
- Manual Distribution
Appodeal.Show(AppodealShowStyle.Interstitial, "placementName");
Appodeal.show(Appodeal.INTERSTITIAL, "placementName");
If the loaded ad can’t be shown for a specific placement, nothing will be shown. If auto caching is enabled, sdk will start to cache another ad, which can affect display rate. To save the loaded ad for future use (for instance, for another placement) check if the ad can be shown before calling show method:
- UPM Distribution
- Manual Distribution
if(Appodeal.CanShow(AppodealAdType.Interstitial, "placementName")) {
Appodeal.Show(AppodealShowStyle.Interstitial, "placementName");
}
You can configure your impression logic for each placement.
If you have no placements, or call Appodeal.Show()
method with a placement that does not exist, the impression
will be tagged with default
placement name and its settings will be applied.
if(Appodeal.canShow(Appodeal.INTERSTITIAL, "placementName")) {
Appodeal.show(Appodeal.INTERSTITIAL, "placementName");
}
You can configure your impression logic for each placement.
If you have no placements, or call Appodeal.show()
method with a placement that does not exist, the impression
will be tagged with default
placement name and its settings will be applied.
Get Predicted eCPM
This method returns expected eCPM for a currently cached advertisement. The amount is calculated based on historical data for the current ad unit.
- UPM Distribution
- Manual Distribution
Appodeal.GetPredictedEcpm(AppodealAdType.Interstitial);
Appodeal.getPredictedEcpm(Appodeal.INTERSTITIAL);
Mute Video Ads
You can mute video ads if calls are muted on the device. For muting you need to call the following method before initializing the SDK.
- UPM Distribution
- Manual Distribution
Appodeal.MuteVideosIfCallsMuted(true);
Appodeal.muteVideosIfCallsMuted(true);