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.
The following sections show you how to load and then show a rewarded ad.
The following code shows you how to attach listeners and load the first rewarded ad:
var REWARDED_AD_UNIT_ID;
if (window.cordova.platformId.toUpperCase() === 'IOS') {
REWARDED_AD_UNIT_ID = '«iOS-ad-unit-ID»';
} else {
// Assume Android
REWARDED_AD_UNIT_ID = '«Android-ad-unit-ID»';
}
var retryAttempt = 0;
function initializeRewardedAds()
{
window.addEventListener('OnRewardedAdLoadedEvent', function (adInfo) {
// Rewarded ad is ready to show. AppLovinMAX.isRewardedAdReady(REWARDED_AD_UNIT_ID) now returns 'true'
// Reset retry attempt
retryAttempt = 0;
});
window.addEventListener('OnRewardedAdLoadFailedEvent', function (adInfo) {
// Rewarded ad failed to load
// AppLovin recommends that you retry with exponentially higher delays, up to a maximum delay (in this case 64 seconds)
retryAttempt++;
var retryDelay = Math.pow(2, Math.min(6, retryAttempt));
setTimeout(function () {
loadRewardedAd();
}, retryDelay * 1000);
});
window.addEventListener('OnRewardedAdClickedEvent', function (adInfo) {});
window.addEventListener('OnRewardedAdDisplayedEvent', function (adInfo) {});
window.addEventListener('OnRewardedAdFailedToDisplayEvent', function (adInfo) {
// Rewarded ad failed to display. AppLovin recommends that you load the next ad.
loadRewardedAd();
});
window.addEventListener('OnRewardedAdReceivedRewardEvent', function (adInfo) {
// The rewarded ad displayed and the user should receive the reward.
});
window.addEventListener('OnRewardedAdHiddenEvent', function (adInfo) {
// Rewarded ad is hidden. Pre-load the next ad.
loadRewardedAd();
});
// Load the first rewarded ad
loadRewardedAd();
}
function loadRewardedAd()
{
AppLovinMAX.loadRewardedAd(REWARDED_AD_UNIT_ID);
}
To show a rewarded ad, call showRewardedAd():
if (AppLovinMAX.isRewardedAdReady(«ad-unit-ID»))
{
AppLovinMAX.showRewardedAd(«ad-unit-ID»);
}
You can receive callbacks to your currency server. To learn how, see the MAX S2S rewarded callback API guide. Then update the Server Side Callback URL in your Edit Ad Unit page.
To set the reward amount and currency:

