Skip to main content

Rewarded Ads

1、Load an ad

  • Developers can preload ads before displaying them.
  • To request a rewarded video ad, you need to declare a TPReward object first, set the listener and load the video creative.
TPReward tpReward = new TPReward(activity,"AdUnitID");
tpReward.setAdListener(new RewardAdListener());
tpReward.loadAd();

2、Show reward video ad

  • When the display opportunity arrives, check whether there is an available ad through the isReady() method; or monitor whether the ad is called back onAdLoaded.
if(tpReward.isReady()) {
tpReward.showAd(activity, null);
}

3、Register Ad Event Callback

  • Note: Don't perform the retry loading method ad in onAdFailed callback – it'll cause a lot of useless requests and could make your app run slowly.
tpReward.setAdListener(new RewardAdListener() {
@Override // Callback when the first ad source is loaded successfully;A load will only be called back once
A load will only be called back once
public void onAdLoaded(TPAdInfo tpAdInfo) {}

@Override // Rewarded video ad clicked
public void onAdClicked(TPAdInfo tpAdInfo) {}

@Override // Rewarded video ad appears on the screen
public void onAdImpression(TPAdInfo tpAdInfo) {}

@Override // Rewarded video ad failed to load
public void onAdFailed(TPAdError error) {}

@Override // Rewarded video ad closed.
public void onAdClosed(TPAdInfo tpAdInfo) {}

@Override // It's time to offer some reward to the user
public void onAdReward(TPAdInfo tpAdInfo) {}

@Override // Rewarded video ad played start
public void onAdVideoStart(TPAdInfo tpAdInfo) {}

@Override // Rewarded video ad played completely
public void onAdVideoEnd(TPAdInfo tpAdInfo) {}

@Override // Rewarded video ad is shown failed(Some advertising platforms support)
public void onAdVideoError(TPAdInfo tpAdInfo, TPAdError error) {}
});

4、Code