Menu

Fully automatic loading of incentive videos


The fully automatic loading mode is a one-stop request maintenance solution launched by TopOn. It can intelligently determine the preloading and caching timing of the next advertisement based on the user's usage status and ad consumption progress with multiple nodes. On the basis of satisfying the developer's operation strategy, it avoids the risk of failure in real-time loading of advertising data and wasted display opportunities, and alleviates users' negative emotions caused by ads not loading or loading not smoothly. Through fully automatic loading of solutions, developers can avoid repeated and cumbersome manual intervention request solutions, and efficiency improvements are immediate.

1. Access process suggestions

  1. Load ads by calling ATRewardedAutoVideo#addAutoLoadAdPlacementID when starting the application
  2. Use ATRewardedAutoVideo#autoLoadRewardedVideoReadyForPlacementID to determine whether the advertisement can be displayed at the location where the advertisement needs to be displayed. false: No operation is required. The SDK will automatically load the advertisement. true: Call ATRewardedAutoVideo#showAutoAd to display the advertisement.
  3. If you need to use advertising scenarios to distinguish data from different business scenarios, please refer to the sample code

Note: If the advertising space is set to full For automatic loading, can no longer call ATRewardedVideo#loadVideoAd(Normal rewarded video ) to load ads

2. API description

ATRewardedAutoVideo:

APIParametersDescription
addAutoLoadAdPlacementIDstring[] placementIDListSet the ad slots that need to be loaded automatically
removeAutoLoadAdPlacementIDstring placementIdRemove ad slots that do not require automatic loading
setAutoLocalExtrastring placementId, string mapJsonSet local parameters for the ad slot
setListenerATRewardedVideoListener listener (Abandoned after version 5.9.51) For details on how to set up listeners, please refer to: Instructions for setting up rewarded video ad events
autoLoadRewardedVideoReadyForPlacementIDstring placementidDetermine whether there is an ad cache
checkAdStatusstring placementidGet the status of the current ad slot (Json string ):
1. isLoading: whether it is loading
2. isReady: whether there is an ad cache (same function as hasAdReady)
3. AdInfo: the current highest priority ad cache information (refer to ATCallbackInfo description)
getAutoValidAdCachesstring placementidGet loading successfully All ad cache information (JSON string)
(refer to ATCallbackInfo description)
showAutoAdstring mapJsonshow ads
showAutoAdstring placementid,Dictionary<string,string> extraUse scene function to display ads more
entryAutoAdScenarioWithPlacementIDstring placementid, string scenarioIDSet up to enter the displayable advertising scenario

3. Set local parameters

4. Load ads

Use the following code to set the full Automatically load rewarded video ads:


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 to learn how to get notified of fully automatic loading of rewarded video ad events (load success/failure, impression, click, video start/end and reward) .

5. Determine whether there is advertising cache

bool isReady = ATRewardedAutoVideo.Instance.autoLoadRewardedVideoReadyForPlacementID(mPlacementId_rewardvideo_all);

6. Display ads

public void showAutoAd()
{
    ATRewardedAutoVideo.Instance.showAutoAd(mPlacementId_rewardvideo_all);
}

When using the scene function:

public void showAutoAd()
{
        // Set up the scene
    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);
}

7. Implement incentives Video event monitoring (note: only supported in V5.9.51 and above)

Please see the callback information details: Callback information description

Use the following method to support setting multiple Listeners

        //Advertisement loaded successfully
        ATRewardedAutoVideo.Instance.client.onAdLoadEvent += onAdLoad; 
        //Ad loading failed
        ATRewardedAutoVideo.Instance.client.onAdLoadFailureEvent += onAdLoadFail;
        //Ad display callback (you can rely on this callback to count display data)
        ATRewardedAutoVideo.Instance.client.onAdVideoStartEvent  += onAdVideoStartEvent;
        //Advertisement ends
        ATRewardedAutoVideo.Instance.client.onAdVideoEndEvent  += onAdVideoEndEvent;
        //Advertisement video playback failed
        ATRewardedAutoVideo.Instance.client.onAdVideoFailureEvent += onAdVideoPlayFail;
        //ad click
        ATRewardedAutoVideo.Instance.client.onAdClickEvent += onAdClick;
        //Advertising incentive callback (you can rely on this listener to issue game incentives)
​
        ATRewardedAutoVideo.Instance.client.onRewardEvent += onReward;
        //Ads are turned off
        ATRewardedAutoVideo.Instance.client.onAdVideoCloseEvent += onAdVideoClosedEvent;

method Define parameters with the following code (Note: The method name can refer to the following code or customize the method name, but the parameters must be consistent)

    //Advertisement loaded successfully
    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 advertising type object, erg is the return 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()));
    }


One more callback: onlyPangolin Support another callback

// ATRewardedVideo watch again video starts playing
ATRewardedVideo.Instance.client.onPlayAgainStart += onRewardedVideoAdAgainPlayStart;
//ATRewardedVideo watch again video failed to play
ATRewardedVideo.Instance.client.onPlayAgainFailure += onRewardedVideoAdAgainPlayFail;
// ATRewardedVideo watch again video playback ends
ATRewardedVideo.Instance.client.onPlayAgainEnd += onRewardedVideoAdAgainPlayEnd;
//ATRewardedVideo to watch the video again click
ATRewardedVideo.Instance.client.onPlayAgainClick += onRewardedVideoAdAgainPlayClicked;
// ATRewardedVideo: Watch the video again to encourage sending
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()));
}


Previous
Rewarded Video Ad
Next
Interstitial ad
Last modified: 2025-05-30Powered by