Skip to main content

Interstitial Ad Units

Create Interstitial Ad Unit#

info

If you miss to Initialize the SDK, this method will fail to return a response.

To create a new interstitial ad, create an MesonInterstitial object.

val interstitialAd = MesonInterstitial(this, "AD_UNIT_ID")

Set the Listener#

Track the ad lifecycle for interstitial ads. All the available events for interstitial ads are listed below.

interstitialAd.setAdListener(object:MesonInterstitialAdListener(){
override fun onAdImpression(interstitialAd: MesonInterstitial, impressionData:JSONObject?) {
}
override fun onAdDisplayed(interstitialAd: MesonInterstitial) {
}
override fun onAdDisplayFailed(interstitialAd: MesonInterstitial) {
}
override fun onAdDismissed(interstitialAd: MesonInterstitial) {
}
override fun onUserLeftApplication(interstitialAd: MesonInterstitial) {
}
override fun onAdLoadSucceeded(interstitialAd: MesonInterstitial) {
}
override fun onAdLoadFailed(interstitialAd: MesonInterstitial, status: MesonAdRequestStatus) {
}
override fun onAdClicked(interstitialAd: MesonInterstitial, params: HashMap<String, Any>) {
}
})

Load Ad#

The publisher can request for an interstitial ad by invoking this method. This will request an ad from all demand sources, select a winner, and make it available on the SDK.

interstitialAd.load()

Show Ad#

The ad is available when load is called. It is shown to the user when show method is called. It is recommended to call this method in the onAdLoadSucceeded callback method or check isReady method to return true and then call show method.

interstitialAd.show()