Loading a Rewarded Ad
The following code shows you how to attach listeners and load the first rewarded ad:
var adUnitID : String = " «ad-unit-ID» " ;
private function initializeRewardedAds () : void
// Attach event callbacks
AppLovinMAXEvents . setRewardedAdLoadedEvent(onRewardedAdLoaded);
AppLovinMAXEvents . setRewardedAdLoadFailedEvent(onRewardedAdFailedToLoad);
AppLovinMAXEvents . setRewardedAdDisplayedEvent(onRewardedAdDisplayed);
AppLovinMAXEvents . setRewardedAdFailedToDisplayEvent(onRewardedAdFailedToDisplay);
AppLovinMAXEvents . setRewardedAdClickedEvent(onRewardedAdClicked);
AppLovinMAXEvents . setRewardedAdReceivedRewardEvent(onRewardedAdReceivedReward);
AppLovinMAXEvents . setRewardedAdHiddenEvent(onRewardedAdHidden);
// Load the first rewarded ad
private function loadRewardedAd () : void
AppLovinMAX . loadRewardedAd(adUnitID);
private function onRewardedAdLoaded ( adEventInfo : AdEventInfo ) : void
// Rewarded ad is ready for you to show. MaxSdk.IsRewardedAdReady(adUnitId) now returns 'true'.
private function onRewardedAdFailedToLoad ( adEventInfo : AdEventInfo ) : void
// Rewarded ad failed to load
// AppLovin recommends that you retry with exponentially higher delays, up to a maximum delay (in this case 64 seconds).
var retryDelay : Number = Math . pow( 2 , Math . min( 6 , retryAttempt));
var timer : Timer = new Timer (retryDelay, 1 );
timer . addEventListener( TimerEvent . TIMER , loadInterstitial);
private function onRewardedAdDisplayed ( adEventInfo : AdEventInfo ) : void {}
private function onRewardedAdFailedToDisplay ( adEventInfo : AdEventInfo ) : void
// Rewarded ad failed to display. AppLovin recommends that you load the next ad.
private function onRewardedAdClicked ( adEventInfo : AdEventInfo ) : void {}
private function onRewardedAdReceivedReward ( adEventInfo : AdEventInfo , reward : AppLovinMAXReward ) : void
// The rewarded ad displayed and the user should receive the reward.
private function onRewardedAdHidden ( adEventInfo : AdEventInfo ) : void
// Rewarded ad is hidden. Pre-load the next ad
Showing a Rewarded Ad
To show a rewarded ad, call ShowRewardedAd()
:
if ( AppLovinMAX . isRewardedAdReady( «ad - unit - ID » ))
AppLovinMAX . showRewardedAd( «ad - unit - ID » );
S2S Rewarded Callbacks
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.
Setting the Amount and Currency for a Rewarded Ad
To set the reward amount and currency:
Click Add S2S Reward Callback in your Edit Ad Unit page:
Add the Server Side Callback URL , Reward Amount , and Rewarded Currency Name :