Interstitial

Interstitial ads are full-screen advertisements. In Appodeal, they are divided into two types - static interstitial and video interstitial.

Both types of ads are requested in parallel when caching and will be shown to be the most expensive of the two.
static interstitial - static full-screen banners.
video interstitial - these are videos that the user can close 5 seconds after the start of viewing.

Initialize interstitial

1. Import the namespaces:

using AppodealAds.Unity.Api;
using AppodealAds.Unity.Common;
2. Add the following code within the Start() method of your main scene’s MonoBehavior: 
Appodeal.initialize("YOUR_APPODEAL_APP_KEY", Appodeal.INTERSTITIAL, consentValue);

Initialization method requires 3 parameters:

  • appKey - appKey is generated when you add an application to Appodeal.
  • adType - Ad types can be combined using "|" operator. For example, Appodeal.INTERSTITIAL | Appodeal.REWARDED_VIDEO.
  • consentValue - is boolean, with 'false' meaning that the user declines to give the consent. Read our guide on collecting consent here.

By default, auto caching is enabled: Appodeal SDK starts to load Interstitial right away after the initialization method is called. The next interstitial ad starts to load after the previous one was shown.

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:

Appodeal.setAutoCache(Appodeal.INTERSTITIAL, false);
To cache interstitial use:
Appodeal.cache(Appodeal.INTERSTITIAL);

Display interstitial

To display interstitial, you need to call the following code

Appodeal.show(Appodeal.INTERSTITIAL);

Check if interstitial is loaded

You can check the status of loading before showing. This method returns a boolean value indicating whether the interstitial is loaded.

Appodeal.isLoaded(Appodeal.INTERSTITIAL);
We recommend you check caching it before trying to show. 

Example:

if(Appodeal.isLoaded(Appodeal.INTERSTITIAL)) {
	Appodeal.show(this, Appodeal.INTERSTITIAL);	
}

Interstitial placements

Appodeal SDK allows you to tag each impression with different placement. For using 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 like this in your activity:

Appodeal.show(this, 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:

if(Appodeal.canShow(Appodeal.INTERSTITIAL, “placementName”)){
	Appodeal.show(this,Appodeal.INTERSTITIAL, “placementName”);
}


You can configure your impression logic for each placement.

If you have no placements, or call Appodeal.show with a placement that does not exist, the impression will be tagged with 'default' placement and its settings will be applied.

Important!

Important! Placement settings affect ONLY ad presentation, not loading or caching.


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. To implement them, you need to follow three steps:

1. Extend your class with IInterstitialAdListener:

YourClassName : IInterstitialAdListener;
2. Then call the following method:
Appodeal.setInterstitialCallbacks(this);

#region Interstitial callback handlers

// Called when interstitial was loaded (precache flag shows if the loaded ad is precache)
public void onInterstitialLoaded(bool isPrecache) 
{ 
	print("Interstitial loaded"); 
} 

// Called when interstitial failed to load
public void onInterstitialFailedToLoad() 
{ 
	print("Interstitial failed"); 
} 

// Called when interstitial was loaded, but cannot be shown (internal network errors, placement settings, or incorrect creative)
public void onInterstitialShowFailed() 
{ 
	print ("Interstitial show failed"); 
} 

// Called when interstitial is shown
public void onInterstitialShown() 
{ 
	print("Interstitial opened"); 
} 

// Called when interstitial is closed
public void onInterstitialClosed() 
{ 
	print("Interstitial closed"); 
} 

// Called when interstitial is clicked
public void onInterstitialClicked() 
{
	print("Interstitial clicked"); 
} 

// Called when interstitial is expired and can not be shown
public void onInterstitialExpired() 
{
	print("Interstitial expired"); 
} 

#endregion

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 .


Get predicted eCPM

This method return expected eCPM for cached ad. Amount is calculated based on historical data for the current ad unit.

public static double getPredictedEcpm(Appodeal.INTERSTITIAL);


Mute video interstitials (Only for android platform)

You can mute video ads if calls is muted on the device. For muting you need to call the following code before the initialization method

Appodeal.muteVideosIfCallsMuted(true);