Menu

Fully automatic loading of incentive videos

The Auto Load mode is a one-stop request maintenance solution launched by Taku that intelligently determines the preloading and caching timing for the next ad across multiple nodes based on user usage status and ad consumption progress. On top of satisfying 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 loading or loading poorly. With the Auto Load solution, developers can avoid the repetitive and cumbersome manual intervention in request schemes, achieving immediate efficiency improvements.

1. Integration Process Suggestions

  1. Call ATRewardedAutoVideo#addAutoLoadAdPlacementID to load ads when the app starts
  2. Use ATRewardedAutoVideo#autoLoadRewardedVideoReadyForPlacementID to check if an ad can be displayed at the location where you want to show it. false: No action needed, the SDK will automatically load ads internally. true: Call ATRewardedAutoVideo#showAutoAd to display the ad
  3. If you need to use ad scenarios to distinguish data for different business scenarios, see the sample code for details

Note: If an ad placement is set to Auto Load, you must no longer call ATRewardedVideo#loadVideoAd (regular rewarded video) for ad loading.

2. API Description

ATRewardedAutoVideo:

API Parameters Description
addAutoLoadAdPlacementID string\[\] placementIDList Set the ad placements that need auto loading
removeAutoLoadAdPlacementID string placementId Remove ad placements that do not need auto loading
setAutoLocalExtra string placementId, string mapJson Set local parameters for the ad placement
setListener ATRewardedVideoListener listener (Deprecated after version 5.9.51) For how to set listeners, see: Rewarded Video Ad Event Settings
autoLoadRewardedVideoReadyForPlacementID string placementid Check if there is a cached ad
checkAdStatus string placementid Get the current ad placement status (JSON string): 1. isLoading: Whether it is loading 2. isReady: Whether there is a cached ad (same as hasAdReady) 3. AdInfo: The highest-priority cached ad info (see ATCallbackInfo Description)
getAutoValidAdCaches string placementid Get all successfully loaded cached ad info (JSON string) (see ATCallbackInfo Description)
showAutoAd string mapJson Display an ad
showAutoAd string placementid, Dictionary Use the scenario feature to display an ad
entryAutoAdScenarioWithPlacementID string placementid, string scenarioID Set entry into a displayable ad scenario

3. Set Local Parameters

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

java Copy
public void setAutoLoadExtra()
{
    Dictionary jsonmap = new Dictionary();
    //If you need to distribute rewards through the developer's server (some ad platforms support this server-side reward), you need to pass the following two keys
    //ATConst.USERID_KEY is required and used to identify each user; ATConst.USER_EXTRA_DATA is optional and will be passed through to the developer's 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);
}

Use the following code to set up auto-loading 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: See below for how to get notified about auto-load rewarded video ad events (load success/failure, impression, click, video start/end, and reward).

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 jsonmap = new Dictionary();
    jsonmap.Add(AnyThinkAds.Api.ATConst.SCENARIO, showingScenario);
    ATRewardedAutoVideo.Instance.showAutoAd(mPlacementId_rewardvideo_all,jsonmap);
}

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

For callback info details, see: Callback Info Description

Use the following method to support setting multiple Listeners:

java Copy
        // Ad loaded successfully
        ATRewardedAutoVideo.Instance.client.onAdLoadEvent += onAdLoad; 
        // Ad load failed
        ATRewardedAutoVideo.Instance.client.onAdLoadFailureEvent += onAdLoadFail;
        // Ad impression callback (can rely on this callback for impression statistics)
        ATRewardedAutoVideo.Instance.client.onAdVideoStartEvent  += onAdVideoStartEvent;
        // Ad playback ended
        ATRewardedAutoVideo.Instance.client.onAdVideoEndEvent  += onAdVideoEndEvent;
        // Video ad playback failed
        ATRewardedAutoVideo.Instance.client.onAdVideoFailureEvent += onAdVideoPlayFail;
        // Ad clicked
        ATRewardedAutoVideo.Instance.client.onAdClickEvent += onAdClick;
        // Ad reward callback (can rely on this listener to distribute in-game rewards)
        ATRewardedAutoVideo.Instance.client.onRewardEvent += onReward;
        // Ad closed
        ATRewardedAutoVideo.Instance.client.onAdVideoCloseEvent += onAdVideoClosedEvent;

The method definition parameters are as follows (Note: You can refer to the code below for method names or use custom method names, but the parameters must be consistent):

java Copy
    // Ad loaded successfully
    public void onAdLoad(object sender,ATAdEventArgs erg)
    {
        Debug.Log("Developer callback onAdLoad :" + erg.placementId);
    }
    // Ad load 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 info
    // 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()));
    }

Watch Another Ad callback: Only Pangle supports the Watch Another Ad callback

java Copy
// Rewarded video watch another ad - video playback started
ATRewardedVideo.Instance.client.onPlayAgainStart += onRewardedVideoAdAgainPlayStart;
// Rewarded video watch another ad - video playback failed
ATRewardedVideo.Instance.client.onPlayAgainFailure += onRewardedVideoAdAgainPlayFail;
// Rewarded video watch another ad - video playback ended
ATRewardedVideo.Instance.client.onPlayAgainEnd += onRewardedVideoAdAgainPlayEnd;
// Rewarded video watch another ad - video clicked
ATRewardedVideo.Instance.client.onPlayAgainClick += onRewardedVideoAdAgainPlayClicked;
// Rewarded video watch another ad - reward granted
ATRewardedVideo.Instance.client.onPlayAgainReward += onAgainReward;

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

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

public void onRewardedVideoAdAgainPlayFail(object sender,ATAdErrorEventArgs erg){
    Debug.Log("Developer onRewardedVideoAdAgainPlayFail------code:" + erg.errorCode + "---message:" + erg.errorMessage);
}

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

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

8. Legacy Auto Load Rewarded Video Listener Implementation (Note: Only for use below V5.9.51, deprecated in new versions)

You can implement a class that implements the ATRewardedVideo Listener interface to get notified about rewarded video ad events: (Note: For Android, all callback methods are not on the Unity main thread, only supported below V5.9.51)

java Copy
class ATCallbackListener : ATRewardedVideoListener {
    // Ad loaded successfully
    public void onRewardedVideoAdLoaded(string placementId){
        Debug.Log("Developer onRewardedVideoAdLoaded------");
    }
    // Ad load failed
    public void onRewardedVideoAdLoadFail(string placementId, string code, string message){
        Debug.Log("Developer onRewardedVideoAdLoadFail------:code" + code + "--message:" + message);
    }
    // Ad playback started
    public void onRewardedVideoAdPlayStart(string placementId, ATCallbackInfo callbackInfo){
        Debug.Log("Developer onRewardedVideoAdPlayStart------");
    }
    // Ad playback ended
    public void onRewardedVideoAdPlayEnd(string placementId, ATCallbackInfo callbackInfo){
        Debug.Log("Developer onRewardedVideoAdPlayEnd------");
    }
    // Ad playback failed
    public void onRewardedVideoAdPlayFail(string placementId, string code, string message){
        Debug.Log("Developer onRewardedVideoAdPlayFail------code:" + code + "---message:" + message);
    }
    // Ad closed, where isReward only indicates whether the onReward() method was called back when onRewardedVideoAdPlayClosed was called back
    public void onRewardedVideoAdPlayClosed(string placementId, bool isReward, ATCallbackInfo callbackInfo){
        Debug.Log("Developer onRewardedVideoAdPlayClosed------isReward:" + isReward);
    }
    // Ad clicked
    public void onRewardedVideoAdPlayClicked(string placementId, ATCallbackInfo callbackInfo){
        Debug.Log("Developer onRewardVideoAdPlayClicked------");
    }
    // Reward granted. Developers can distribute rewards in this callback. It generally precedes the onRewardedVideoAdPlayClosed callback, but this is not guaranteed for server-side rewards
    public void onReward(string placementId, ATCallbackInfo callbackInfo){
        Debug.Log("Developer onReward------");
    }

      // v5.8.10 added Ad Source-level callbacks
      // Ad Source started loading
    public void startLoadingADSource(string placementId, ATCallbackInfo callbackInfo){
        Debug.Log("Developer startLoadingADSource------");
    }
      // Ad Source loading completed
        public void finishLoadingADSource(string placementId, ATCallbackInfo callbackInfo){
        Debug.Log("Developer finishLoadingADSource------");
    }
      // Ad Source failed
        public void failToLoadADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message){
        Debug.Log("Developer failToLoadADSource------");
    }
      // Ad Source started bidding
        public void startBiddingADSource(string placementId, ATCallbackInfo callbackInfo){
               Debug.Log("Developer startBiddingADSource------");
    }
      // Ad Source bidding succeeded
        public void finishBiddingADSource(string placementId, ATCallbackInfo callbackInfo){
        Debug.Log("Developer finishBiddingADSource------");
    }
      // Ad Source bidding failed
        public void failBiddingADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message){
        Debug.Log("Developer failBiddingADSource------");
    }
}

Watch Another Ad callback: Only Pangle supports the Watch Another Ad callback

java Copy
class ATCallbackListener : ATRewardedVideoExListener {
        // Rewarded video watch another ad - video playback started
        public void onRewardedVideoAdAgainPlayStart(string placementId, ATCallbackInfo callbackInfo) {
            Debug.Log("Developer onRewardedVideoAdAgainPlayStart------");
        }
        // Rewarded video watch another ad - video playback ended
        public void onRewardedVideoAdAgainPlayEnd(string placementId, ATCallbackInfo callbackInfo) {
            Debug.Log("Developer onRewardedVideoAdAgainPlayEnd------");
        }
        // Rewarded video watch another ad - video playback failed
        public void onRewardedVideoAdAgainPlayFail(string placementId, string code, string message) {
            Debug.Log("Developer onRewardedVideoAdAgainPlayFail------");
        }
        // Rewarded video watch another ad - video clicked
        public void onRewardedVideoAdAgainPlayClicked(string placementId, ATCallbackInfo callbackInfo) {
            Debug.Log("Developer onRewardedVideoAdAgainPlayClicked------");
        }
        // Rewarded video watch another ad - reward granted
        public void onAgainReward(string placementId, ATCallbackInfo callbackInfo) {
            Debug.Log("Developer onAgainReward------");
        }
}

Note: The code snippets in this section are from the videoScenes.cs demo project in our Demo.

Previous
Rewarded Video Ad
Next
Interstitial ad
Last modified: 2026-07-02Powered by