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.

1. 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 shown.

To disable automatic caching for interstitials, use the code below before SDK initialization:

Appodeal.setAutocache(false, types: .interstitial)
To cache an interstitial, use:
Appodeal.cacheAd(.interstitial)
Read more on manual caching in our FAQ.

2. Checking if Interstitial Has Been 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.

Appodeal.isReadyForShow(with: .interstitial)
We recommend you to check ad caching before trying to show it. 

3. Displaying Interstitial

Appodeal.showAd(AppodealShowStyle.interstitial, rootViewController: self)

4. Interstitial 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.

Appodeal.showAd(.interstitial, 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:


Appodeal.canShow(.interstitial, 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.

Important!

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

5. Using Interstitial 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:

// 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:

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(){
        
    }
}

All callbacks are called on the main thread.

6. Getting 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.

Appodeal.predictedEcpm(for: .interstitial)

7. Checking if Interstitial Has Been Initialized

Appodeal.isInitialized(for: .interstitial)

Returns true if interstitial was initialized.

8. Checking if Autocache is Enabled for Interstitial

Appodeal.isAutocacheEnabled(.interstitial)

Returns true if autocache is enabled for interstitial.