Interstitial

class Interstitial(val location: String, callback: InterstitialCallback, mediation: Mediation? = null) : Ad

Interstitial is a full-screen ad. To show an interstitial, it first needs to be cached. Trying to show a not-cached interstitial will always fail, so it is recommended to always check if the ad is cached first. You can create and cache as many interstitial ads as you want, but only one can be presented at a time.

A basic implementation would look like this:

fun createAndCacheInterstitial() {
this.interstitial = Interstitial("location", callback)
this.interstitial.cache()
}

fun showInterstitial() {
if (this.interstitial.isCached()) {
this.interstitial.show()
}
}

// Callback implementation

fun didCacheAd(event: CacheEvent, error: CacheError?) {
if (error != null) {
// Handle error, possibly scheduling a retry
}
}

fun willShowAd(event: ShowEvent) {
// Pause ongoing processes
}

fun didShowAd(event: ShowEvent, error: ShowError?) {
if (error != null) {
// Resume paused processes
}
}

fun didDismissAd(event: DismissEvent) {
// Resume paused processes
}

For more information on integrating and using the Chartboost SDK, please visit our help site documentation at https://help.chartboost.com.

Constructors

Link copied to clipboard
constructor(location: String, callback: InterstitialCallback, mediation: Mediation? = null)

Properties

Link copied to clipboard
open override val location: String

Chartboost location for the ad. Used to obtain ads with increased performance.

Functions

Link copied to clipboard
open override fun cache()

Caches an ad. This method will first check if there is a cached ad and, if found, will do nothing. If no cached ad exists, the method will attempt to fetch it from the Chartboost server. Implement didCacheAd(event: CacheEvent, error: CacheError?) to be notified of the cache request result.

open override fun cache(bidResponse: String?)

Caches an ad with bid response. This method will parse the provided bid response and cache the ad accordingly.

Link copied to clipboard
open override fun clearCache()

Clears the ad cache. This will do nothing if there's no cached ad. Otherwise, it will remove any data related to the ad, bringing the ad instance back to a non-cached state. After calling this method, you may call cache again and a new ad will be fetched.

Link copied to clipboard
open override fun isCached(): Boolean

Determines if a cached ad exists.

Link copied to clipboard
open override fun show()

Shows an ad. This method will first check if there is a cached ad; if found, it will present it.