Skip to main content

Rewarded Ad Units

Create Rewarded Ad Unit#

info

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

All the steps to configure and show the rewarded ad are same as the interstitial except rewarded ads have an additional callback method onRewardsUnlocked for rewarding the user when they complete watching the ad content.

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

val rewardedAd = MesonInterstitial(this, "AD_UNIT_ID")

Set the Listener#

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

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

Load Ad#

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

rewardedAd.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.

rewardedAd.show()