Menu

Fully automatic loading of incentive videos

The Auto Load mode is a one-stop request management solution launched by TopOn, which can intelligently determine the preloading and caching timing of the next ad based on the user's usage status and ad consumption progress at multiple nodes. On the basis of meeting the developer's operational strategy, it avoids the risk of real-time ad loading failures and wasted impression opportunities, reducing negative user sentiment caused by ads not being loaded or loading not being smooth. With the Auto Load solution, developers can avoid repetitive and cumbersome manual intervention in request schemes, with immediate and noticeable efficiency improvements.

1. Integration Process Suggestions

  1. When the app starts, load the ad by calling ATRewardedAutoVideo#addAutoLoadAdPlacementID.
  2. At the position where you need to display an ad, check whether it can be shown via ATRewardedAutoVideo#autoLoadRewardedVideoReadyForPlacementID. false: No action is needed; the SDK internally will automatically load the ad. true: Call ATRewardedAutoVideo#showAutoAd to display the ad.
  3. If you need to use ad scenarios to differentiate data for different business scenarios, refer to the sample code for details.

Note: If a placement is set to Auto Load, you must not call ATRewardedVideo#loadVideoAd (regular rewarded video) to load ads.

2. API Description

ATRewardedAutoVideo:

API Parameters Description
addAutoLoadAdPlacementID string\[\] placementIDList Set the placements that need to be auto-loaded
removeAutoLoadAdPlacementID string placementId Remove the placements that do not need to be auto-loaded
setAutoLocalExtra string placementId, string mapJson Set local parameters for the placement
setListener ATRewardedVideoListener listener (Deprecated after version 5.9.51) For how to set the listener, refer to: Rewarded Video Ad Event Setup Instructions
autoLoadRewardedVideoReadyForPlacementID string placementid Check if there is an ad cache
showAutoAd string mapJson Show an ad
showAutoAd string placementid, Dictionary extra Show an ad using the scenario feature
entryAutoAdScenarioWithPlacementID string placementid, string scenarioID Set entry into a displayable ad scenario
  1. Set Local Parameters

If you need to support server-side reward callbacks, you need to pass the parameters before configuring the auto load placement (effective for the next rewarded video ad load). Sample code:

java Copy
public void setAutoLoadExtra()
{
    Dictionary<string> jsonmap = new Dictionary<string>();
    // If you need to grant rewards through your own server (some ad networks support this server-side reward), you need to pass the following two keys
    // ATConst.USERID_KEY is required, used to identify each user; ATConst.USER_EXTRA_DATA is an optional parameter, and once passed, it will be forwarded to your server
    jsonmap.Add(ATConst.USERID_KEY, "test_user_id");
    jsonmap.Add(ATConst.USER_EXTRA_DATA, "test_user_extra_data");

    ATRewardedAutoVideo.Instance.setAutoLocalExtra(mPlacementId_rewardvideo_all, jsonmap);
}</string></string>

Use the following code to set up Auto Load for rewarded video ads:

java Copy
public void addAutoLoadAdPlacementID()
{


    ATRewardedAutoVideo.Instance.client.onAdLoadEvent += onAdLoad; 
    ATRewardedAutoVideo.Instance.client.onAdLoadFailureEvent += onAdLoadFail;  
    ATRewardedAutoVideo.Instance.client.onAdVideoStartEvent  += onAdVideoStartEvent;
    ATRewardedAutoVideo.Instance.client.onAdVideoEndEvent  += onAdVideoEndEvent;       
    ATRewardedAutoVideo.Instance.client.onAdVideoFailureEvent += onAdVideoPlayFail;        
    ATRewardedAutoVideo.Instance.client.onAdClickEvent += onAdClick;
    ATRewardedAutoVideo.Instance.client.onRewardEvent += onReward;

    ATRewardedAutoVideo.Instance.client.onAdVideoCloseEvent += onAdVideoClosedEvent;


    string[] jsonList = {mPlacementId_rewardvideo_all};
    ATRewardedAutoVideo.Instance.addAutoLoadAdPlacementID(jsonList);
}

Note: Please refer to the following section to learn how to receive notifications about Auto Load rewarded video ad events (load success/failure, display, click, video start/end, and reward).

5. Check if There Is an Ad Cache

java Copy
bool isReady = ATRewardedAutoVideo.Instance.autoLoadRewardedVideoReadyForPlacementID(mPlacementId_rewardvideo_all);
java Copy
public void showAutoAd()
{
    ATRewardedAutoVideo.Instance.showAutoAd(mPlacementId_rewardvideo_all);
}

When using the scenario feature:

java Copy
public void showAutoAd()
{
        // Set entry into scenario
    ATRewardedAutoVideo.Instance.entryAutoAdScenarioWithPlacementID(mPlacementId_rewardvideo_all, showingScenario);
    Dictionary<string string=""> jsonmap = new Dictionary<string string="">();
    jsonmap.Add(AnyThinkAds.Api.ATConst.SCENARIO, showingScenario);
    ATRewardedAutoVideo.Instance.showAutoAd(mPlacementId_rewardvideo_all,jsonmap);
}</string></string>

7. Implement Rewarded Video Event Listeners (Note: Only supported in V5.9.51 and above)

For callback information details, please see: Callback Information Description

Use the following method to support setting multiple listeners:

java Copy
        // Ad loading succeeded
        ATRewardedAutoVideo.Instance.client.onAdLoadEvent += onAdLoad; 
        // Ad loading failed
        ATRewardedAutoVideo.Instance.client.onAdLoadFailureEvent += onAdLoadFail;
        // Ad display callback (this callback can be relied on for impression statistics)
        ATRewardedAutoVideo.Instance.client.onAdVideoStartEvent  += onAdVideoStartEvent;
        // Ad playback ended
        ATRewardedAutoVideo.Instance.client.onAdVideoEndEvent  += onAdVideoEndEvent;
        // Ad video playback failed
        ATRewardedAutoVideo.Instance.client.onAdVideoFailureEvent += onAdVideoPlayFail;
        // Ad clicked
        ATRewardedAutoVideo.Instance.client.onAdClickEvent += onAdClick;
        // Ad reward callback (this listener can be relied on to grant in-game rewards)
        ATRewardedAutoVideo.Instance.client.onRewardEvent += onReward;
        // Ad dismissed
        ATRewardedAutoVideo.Instance.client.onAdVideoCloseEvent += onAdVideoClosedEvent;

The method parameter definitions are as follows in the code (Note: The method name can follow the code below or be a custom method name, but the parameters must be consistent.):

java Copy
    // Ad loading succeeded
    public void onAdLoad(object sender,ATAdEventArgs erg)
    {
        Debug.Log("Developer callback onAdLoad :" + erg.placementId);
    }
    // Ad loading failed
    public void onAdLoadFail(object sender,ATAdErrorEventArgs erg )
    {
        Debug.Log("Developer callback onAdLoadFail :" + erg.placementId + "--erg.code:" + code + "--msg:" + erg.message);
    }

     public void onAdVideoStartEvent(object sender, ATAdEventArgs erg) {
        Debug.Log("Developer onAdVideoStartEvent------" + "->" + JsonMapper.ToJson(erg.callbackInfo.toDictionary()));
    } 

    public void onAdVideoEndEvent(object sender, ATAdEventArgs erg)
    {
        Debug.Log("Developer onAdVideoEndEvent------" + "->" + JsonMapper.ToJson(erg.callbackInfo.toDictionary()));
    }


    public void onAdVideoPlayFail(object sender, ATAdErrorEventArgs erg)
    {
        Debug.Log("Developer onAdVideoClosedEvent------" + "->" + JsonMapper.ToJson(erg.errorMessage));
    }


    // sender is the ad type object, erg is the returned information
    // Ad clicked
    public void onAdClick(object sender,ATAdEventArgs erg)
    {
        Debug.Log("Developer callback onAdClick :" + erg.placementId);
    }

    public void onReward(object sender, ATAdEventArgs erg)
    {
        Debug.Log("Developer onReward------" + "->" + JsonMapper.ToJson(erg.callbackInfo.toDictionary()));
    }


    public void onAdVideoClosedEvent(object sender, ATAdEventArgs erg)
    {
        Debug.Log("Developer onAdVideoClosedEvent------" + "->" + JsonMapper.ToJson(erg.callbackInfo.toDictionary()));
    }
Previous
Rewarded Video Ad
Next
Interstitial ad
Last modified: 2026-07-03Powered by