Rewarded Ads
This guide explains how to integrate rewarded ads into a Cordova app.
Rewarded ads let you offer users in-app items, such as continued gameplay, virtual currency, or other rewards, in exchange for their engagement with ads. Rewarded ads boost engagement because users receive a tangible benefit for their time.
Rewarded ad management in Cordova code is handled through the casai.rewardedAd object.
The rewarded ad is displayed as an overlay on top of all app content and cannot be added to the Cordova WebView DOM.
Below is a diagram showing the ad lifecycle and how autoload affects it.

Load Ad
CAS provides an option to enable autoload to simplify your app logic.
Before using the ad, you should decide whether to enable autoload, or manually manage each ad loading cycle in your code.
When autoload is enabled, a new ad will be automatically loaded after each display, and loading failures will trigger automatic retry attempts.
casai.rewardedAd
.load({
autoReload: true,
})
.then(function () {
// Called when an ad is successfully loaded.
console.log('Loaded');
})
.catch(function (error) {
// Called when an ad load failed.
console.log('Load failed:', error);
});
Manual load mode is useful when you only need to show a single ad per app screen, and the screens change frequently.
When you want to manually control ad loading, use the load({ autoReload: false }) function.
All parameters are optional — you can omit them and use the defaults if that fits your use case.
Ad content may take some time to load after creating an ad instance. To ensure the ad displays instantly when needed, load the ad instance in advance.
You can use the casai_ad_loaded document event to be notified when the ad is ready for display.
- Read more about
AdContentInfostructure in Impression Level Data. - Read more about AdError structure.
Show Ad
Be sure to listen to the casai_ad_reward event or handle the resolved result from show() and reward the user for watching an ad.
You can choose when to show the ad by calling show():
casai.rewardedAd
.show()
.then(function (info) {
if (info.isUserEarnReward) {
// Called when the user has earned the reward.
console.log('Reward the user for watching the ad');
} else {
// Called when the ad dismissed full screen content without a reward.
console.log('Dismissed without reward');
}
})
.catch(function (error) {
// Called when the ad failed to show full screen content.
console.log('Failed to show:', error);
});
The reward event (casai_ad_reward) differs from the dismissal event (casai_ad_dismissed) — the user might not complete the ad and thus not earn a reward.
If the ad is not ready at that moment, the casai_ad_show_failed document event will be triggered with a reason provided in the AdError.
You have the option to check isLoaded() if it's required by your app's logic.
if (await casai.rewardedAd.isLoaded()) {
// The ad is loaded here
}
Listening for the Ad Clicked
The plugin allows you to listen for the casai_ad_clicked event, which is triggered whenever a user clicks an ad. This can be useful for analytics, custom tracking, or UI reactions. You can check e.detail.format to determine the ad format.
function onAdClicked(e) {
if (e.detail.format === casai.Format.REWARDED) {
// Called when a click is recorded for an Rewarded ad.
}
}
document.addEventListener('casai_ad_clicked', onAdClicked);
Mute Ad sounds
Indicates if the application’s audio is muted. Affects initial mute state for fullscreen ads. Use this method only if your application has its own volume controls (e.g., custom music or sound effect muting).
casai.setAdSoundsMuted(true);
Not muted by default.
Release ad resource
Be sure to release ad resources when no longer needed:
casai.rewardedAd.destroy();