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 the 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 a MesonInterstitial object.
val rewardedAd = MesonInterstitial(this, "AD_UNIT_ID")
MesonInterstitial interstitialAd = new MesonInterstitial(this, "AD_UNIT_ID");
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, mesonAdData: MesonAdData?) {
}
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: Map<Any, Any>?) {
}
})
rewardedAd.setAdListener(new MesonInterstitialAdListener(){
@Override
public void onAdDisplayed(@NonNull MesonInterstitial mesonInterstitial) {
super.onAdDisplayed(mesonInterstitial);
}
@Override
public void onAdDismissed(@NonNull MesonInterstitial mesonInterstitial) {
super.onAdDismissed(mesonInterstitial);
}
@Override
public void onAdDisplayFailed(@NonNull MesonInterstitial mesonInterstitial) {
super.onAdDisplayFailed(mesonInterstitial);
}
@Override
public void onRewardsUnlocked(@NonNull MesonInterstitial mesonInterstitial, @Nullable Map<Object, ?> map) {
super.onRewardsUnlocked(mesonInterstitial, map);
}
@Override
public void onAdLoadSucceeded(MesonInterstitial mesonInterstitial) {
super.onAdLoadSucceeded(mesonInterstitial);
}
@Override
public void onAdLoadFailed(MesonInterstitial mesonInterstitial, @NonNull MesonAdRequestStatus mesonAdRequestStatus) {
super.onAdLoadFailed(mesonInterstitial, mesonAdRequestStatus);
}
@Override
public void onAdClicked(MesonInterstitial mesonInterstitial, @NonNull HashMap<String, Object> hashMap) {
super.onAdClicked(mesonInterstitial, hashMap);
}
@Override
public void onAdImpression(MesonInterstitial mesonInterstitial, @Nullable MesonAdData mesonAdData) {
super.onAdImpression(mesonInterstitial, jsonObject);
}
});
The publisher can request 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()
rewardedAd.load()
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 isAdReady
method to return true and then call show method.
rewardedAd.show()
rewardedAd.show();