Interstitial
Interstitial ads are full-screen ads. In Appodeal, they are divided into two types - static interstitial and video interstitial.
Both ad types are requested when caching, the one shown being the more expensive of the two.
Static interstitial - static full-screen banners.
Video interstitial - videos that can be closed 5 seconds after the start.
Manual Caching
By default, auto caching is enabled: Appodeal SDK starts to load Interstitial right after the initialization method is called.
The next interstitial ad starts to load after the previous one has been closed.
To disable automatic caching for interstitials, use the code below before SDK initialization:
- Swift
- Objective C
Appodeal.setAutocache(false, types: .interstitial)
[Appodeal setAutocache: NO types:AppodealAdTypeInterstitial];
To cache an interstitial, use:
- Swift
- Objective C
Appodeal.cacheAd(.interstitial)
[Appodeal cacheAd:AppodealAdTypeInterstitial];
Read more on manual caching in our FAQ.
Check If Ad Is Loaded
You can check if the ad has been loaded before showing it. This method returns a boolean value indicating whether or not the interstitial has been loaded.
- Swift
- Objective C
Appodeal.isReadyForShow(with: .interstitial)
[Appodeal isReadyForShowWithStyle: AppodealShowStyleInterstitial];
We recommend you to check ad caching before trying to show it.
Display
- Swift
- Objective C
Appodeal.showAd(AppodealShowStyle.interstitial, rootViewController: self)
[Appodeal showAd:AppodealShowStyleInterstitial rootViewController:self];
Placements
Appodeal SDK allows you to tag each impression with different placement. To be able to use placements, you need to create them in Appodeal Dashboard. Read more about placements.
- Swift
- Objective C
Appodeal.showAd(.interstitial, forPlacement: placement, rootViewController: self)
[Appodeal showAd:AppodealShowStyleInterstitial forPlacement:placement rootViewController:self];
If the loaded ad can't be shown in a specific placement, nothing will be shown. If auto caching is enabled, the 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:
- Swift
- Objective C
Appodeal.canShow(.interstitial, forPlacement: placement)
[Appodeal canShow:AppodealAdTypeInterstitial forPlacement:placement];
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 with corresponding settings applied.
Placement settings affect ONLY ad presentation, not loading or caching.
Callbacks
Callbacks are used to track different events in the lifecycle of an ad, e.g., when an ad was clicked on or closed. To get them, you need to set the delegate as follows:
- Swift
- Objective C
// set delegate
Appodeal.setInterstitialDelegate(self)
// set delegate
[Appodeal setInterstitialDelegate:self];
Usually, the class that implements interstitials is also the delegate
class. That's why the delegate property can be set to self
.
Now you can use the following callback methods:
- Swift
- Objective C
extension YourViewController: AppodealInterstitialDelegate {
// Method called when precache (cheap and fast load) or usual interstitial view did load
//
// - Warning: If you want show only expensive ad, ignore this callback call with precache equal to YES
// - Parameter precache: If precache is YES it's mean that precache loaded
func interstitialDidLoadAdIsPrecache(_ precache: Bool) {
}
// Method called if interstitial mediation failed
func interstitialDidFailToLoadAd() {
}
// Method called if interstitial mediation was success, but ready ad network can't show ad or
// ad presentation was to frequently according your placement settings
func interstitialDidFailToPresent() {
}
// Method called when interstitial will display on screen
func interstitialWillPresent() {
}
// Method called after interstitial leave screeen
func interstitialDidDismiss() {
}
// Method called when user tap on interstitial
func interstitialDidClick() {
}
// Method called when interstitial did expire and could not be shown
func interstitialDidExpired(){
}
}
- (void)interstitialDidLoadAdIsPrecache:(BOOL)precache; //interstitial was loaded (precache flag shows if the loaded ad is precache)
- (void)interstitialDidFailToLoadAd; //interstitial failed to load
- (void)interstitialDidFailToPresent; //interstitial was loaded but failed to present (may be caused by inner ad network error, placement settings or invalid creative)
- (void)interstitialWillPresent; //interstitial was loaded and will present
- (void)interstitialDidDismiss; //interstitial was closed
All callbacks are called on the main thread.
Get Predicted eCPM
This method returns the expected eCPM for the cached ad. The amount is calculated based on historical data for the current ad unit.
- Swift
- Objective C
Appodeal.predictedEcpm(for: .interstitial)
[Appodeal predictedEcpmForAdType: AppodealAdTypeInterstitial];
Check If Ad Is Initialized
- Swift
- Objective C
Appodeal.predictedEcpm(for: .interstitial)
[Appodeal predictedEcpmForAdType: AppodealAdTypeInterstitial];
Returns true
if interstitial was initialized.
Check If Autocache Is Enabled
- Swift
- Objective C
Appodeal.isAutocacheEnabled(.interstitial)
[Appodeal isAutocacheEnabled: AppodealAdTypeInterstitial];
Returns true
if autocache is enabled for interstitial.