Skip to content

Rewarded Ads

Loading a Rewarded Ad

The following code shows you how to attach listeners and load the first rewarded ad:

final String _rewarded_ad_unit_ID = Platform.isAndroid ? "«Android-ad-unit-ID»" : "«iOS-ad-unit-ID»";
const int _maxExponentialRetryCount = 6;
var _rewardedAdRetryAttempt = 0;
void initializeRewardedAd() {
AppLovinMAX.setRewardedAdListener(RewardedAdListener(onAdLoadedCallback: (ad) {
// Rewarded ad is ready to show. AppLovinMAX.isRewardedAdReady(_rewarded_ad_unit_ID) now returns 'true'.
print('Rewarded ad loaded from ' + ad.networkName);
// Reset retry attempt
_rewardedAdRetryAttempt = 0;
}, onAdLoadFailedCallback: (adUnitId, error) {
// Rewarded ad failed to load.
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds).
_rewardedAdRetryAttempt = _rewardedAdRetryAttempt + 1;
if (_rewardedAdRetryAttempt > _maxExponentialRetryCount) return;
int retryDelay = pow(2, min(_maxExponentialRetryCount, _rewardedAdRetryAttempt)).toInt();
print('Rewarded ad failed to load with code ' + error.code.toString() + ' - retrying in ' + retryDelay.toString() + 's');
Future.delayed(Duration(milliseconds: retryDelay * 1000), () {
}, onAdDisplayedCallback: (ad) {
}, onAdDisplayFailedCallback: (ad, error) {
}, onAdClickedCallback: (ad) {
}, onAdHiddenCallback: (ad) {
}, onAdReceivedRewardCallback: (ad, reward) {
}));}void loadRewardedAd() { AppLovinMAX.loadRewardedAd(_rewarded_ad_unit_id);}

Showing a Rewarded Ad

To show a rewarded ad, call showRewardedAd():

bool isReady = (await AppLovinMAX.isRewardedAdReady(_rewarded_ad_unit_ID))!;
if (isReady) {

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:

  1. Click Add S2S Reward Callback in your Edit Ad Unit page: Ad Type: ☐App Open, ☐Banner, ☐Interstitial, ☐MRec, ☐Native, ☑Rewarded. Add S2S Reward Callback.
  2. Add the Server Side Callback URL, Reward Amount, and Rewarded Currency Name: Ad Type: ☐App Open, ☐Banner, ☐Interstitial, ☐MRec, ☐Native, ☑Rewarded. Hide Callback Settings. Server Side Callback URL form field. Reward Amount form field. Rewarded Currency Name form field. AppLovin Event Key form field.