Skip to main content

Rewarded

Users can voluntarily choose to interact with this type of ad in exchange for in-app rewards, such as earning extra points or additional lives in games.

Introduction

Rewarded ads are typically displayed on game pages within an App. Users receive corresponding rewards after watching a full-screen ad (supports landscape mode). Ad content supports images and videos. Effect image:

Full Screen

We recommend that you download and experience the HiSavana Demo to gain a more intuitive and in-depth understanding of the SDK's features and usage. Through the Demo, you can quickly get started and explore its application in real-world scenarios.

Loading Ads

Please configure the corresponding parameters and callback listeners. Be sure to carefully review the documentation for the applicable ad placement types in relevant callbacks to avoid integration discrepancies.

// Initialize the rewarded ad object, where "rewarded_id" is the rewarded ad unit ID
TRewarded tRewarded = new TRewarded("rewarded_id");
// Set the ad listener
tRewarded.setAdListener(new TAdListener());
// Load the ad
tRewarded.loadAd();

// Ad listener, monitors callbacks for ad request timeout, loading completion (fill), display, click, exception, close, and reward actions
private static class TAdListener extends AdListener {

// Exception callback (applicable ad slots: all ad slots)
@Override
public void onError(TaErrorCode adError) {
Log.d(TAG,"Ad failed callback");
}

// Loading completion callback (applicable ad slots: Splash, Interstitial, Banner, Reward)
@Override
public void onAdLoaded() {
Log.d(TAG,"Ad loaded callback");
}

// Click callback (applicable ad slots: Splash, Interstitial, Banner, Reward)
@Override
public void onAdClicked() {
Log.d(TAG,"Ad click callback");
}

// Display callback (applicable ad slots: Splash, Interstitial, Banner, Reward)
@Override
public void onAdShow() {
Log.d(TAG,"Ad show callback");
}

// Request timeout callback (applicable ad slots: all ad slots)
@Override
public void onTimeOut() {
Log.d(TAG,"Ad request timeout callback");
}

// Close callback (applicable ad slots: Splash, Interstitial, Reward)
@Override
public void onAdClosed() {
Log.d(TAG,"Ad close callback");
}

// Reward callback (applicable ad slots: Reward)
@Override
public void onRewarded() {
Log.d(TAG,"Ad rewarded callback");
}

}

Display Ads

Please display the rewarded ad.

// If the current ad is loaded successfully and within the delivery period, display it; otherwise, do not display it
if (tRewarded != null && tRewarded.isReady()) {
tRewarded.show();
}

Destroy Ads

Please recycle ads promptly, otherwise the App may experience memory leaks.

// After exiting the ad scenario, please destroy the ad object.
@Override
protected void onDestroy() {
super.onDestroy();
if (tRewarded != null) {
tRewarded.destroy();
tRewarded = null;
}
}

Other APIs

API CallDescription
tRewarded.isReady()If the current ad is loaded successfully and within the delivery period, display it; otherwise, do not display it