Skip to content

Rewarded Ads

Loading a Rewarded Ad

To load a rewarded ad, first obtain an instance of a MaxRewardedAd object that corresponds to your rewarded ad unit. Then call that object’s loadAd() method. Implement MaxRewardedAdListener so that you are notified when your ad is ready. This also notifies you of other ad-related events.

public class ExampleActivity extends Activity
implements MaxRewardedAdListener
{
private MaxRewardedAd rewardedAd;
private int retryAttempt;
void createRewardedAd()
{
rewardedAd = MaxRewardedAd.getInstance( "«ad-unit-ID»", getApplicationContext() );
rewardedAd.setListener( this );
rewardedAd.loadAd();
}
// MAX Ad Listener
@Override
public void onAdLoaded(final MaxAd maxAd)
{
// Rewarded ad is ready to be shown. rewardedAd.isReady() will now return 'true'
// Reset retry attempt
retryAttempt = 0;
}
@Override
public void onAdLoadFailed(final String adUnitId, final MaxError 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)
retryAttempt++;
long delayMillis = TimeUnit.SECONDS.toMillis( (long) Math.pow( 2, Math.min( 6, retryAttempt ) ) );
new Handler().postDelayed( new Runnable()
{
@Override
public void run()
{
rewardedAd.loadAd();
}
}, delayMillis );
}
@Override
public void onAdDisplayFailed(final MaxAd maxAd, final MaxError error)
{
// Rewarded ad failed to display. AppLovin recommends that you load the next ad.
rewardedAd.loadAd();
}
@Override
public void onAdDisplayed(final MaxAd maxAd) {}
@Override
public void onAdClicked(final MaxAd maxAd) {}
@Override
public void onAdHidden(final MaxAd maxAd)
{
// rewarded ad is hidden. Pre-load the next ad
rewardedAd.loadAd();
}
@Override
public void onUserRewarded(final MaxAd maxAd, final MaxReward maxReward)
{
// Rewarded ad was displayed and user should receive the reward
}
}

Showing a Rewarded Ad

To show a rewarded ad, call showAd( this ) on the MaxRewardedAd object you created.

if ( rewardedAd.isReady() )
{
// `this` is the activity that will be used to show the ad
rewardedAd.showAd( this );
}

Accessing the Amount and Currency for a Rewarded Ad

To access the reward amount and currency, override the onUserRewarded() callback:

@Override
public void onUserRewarded(final MaxAd ad, final MaxReward reward)
{
System.out.println( "Rewarded user: " + reward.getAmount() + " " + reward.getLabel() );
}

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.