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 SSP 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.setListener(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");
}

// onTimeOut() is deprecated. The SDK combines the current request result with its ad cache when loading times out:
// if no usable ad is available, onError(...) is called; if a usable ad has already been obtained, including from cache,
// the load is treated as successful and onAdLoaded(...) is called instead of onError(...).
@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
tRewarded.isOfflineAd()Whether the current ad is offline
tRewarded.getFillAdType()Whether the current filled ad is offline or online; 1: offline ad, 0: online ad, -1: no fill
tRewarded.getBidPrice()Gets the effective bid price of the ad, in cents/eCPM