Menu

Rewarded Video Ad

1. Introduction to rewarded video advertising

Rewarded video ads are rewarded video ads that aggregate other third-party advertising platforms. You can use ATRewardedVideo's API to load and play ads. Currently, two integration methods are supported, the details are as follows:

Mode (choose one)Description
Manual request modeYou choose the appropriate time to load the ad through the API , please refer to the integration suggestions below the document for details
Fully automatic loading modeTopOn's one-stop request maintenance solution can automatically determine the preloading and caching timing of the next advertisement based on the user's usage status and ad consumption progress to achieve better results. Loading effect, see for details: Fully automatic loading mode for rewarded video ads

2. Advice on access procedures

  1. Load ads by calling ATRewardedVideo#loadVideoAd when launching the app
  2. Use ATRewardedVideo#hasAdReady to determine whether ads can be displayed where they need to be displayed.
  3. Ad preloading:
  4. If you need to use scenarios Distinguish the data of different business scenarios, please refer to the sample code for details​

3. API Description

ATRewardedVideo:

APIParametersDescription
loadVideoAdstring placementid, Dictionary<string,string> extra
setListener< /td>ATRewardedVideoListener listenerSet the listening callback interface(Abandoned after version 5.9.51) For details on how to set the listener, please refer to: Rewarded video ad event setting instructions
hasAdReadystring placementidDetermine whether there is Ad cache
showAdstring placementidDisplay ads
showAdstring placementid,Dictionary<string,string> extraUse the scene function to display ads more
entryScenarioWithPlacementIDstring placementid, string scenarioIDSettings can be entered Display advertising scene

4. Load rewarded video

Use the following code to load rewarded video ads:

public void loadVideo()
{
    ATRewardedVideo.Instance.client.onAdLoadEvent += onAdLoad; 
    ATRewardedVideo.Instance.client.onAdLoadFailureEvent += onAdLoadFail;
    ATRewardedVideo.Instance.client.onAdVideoStartEvent  += onAdVideoStartEvent;
    ATRewardedVideo.Instance.client.onAdVideoEndEvent  += onAdVideoEndEvent;
    ATRewardedVideo.Instance.client.onAdVideoFailureEvent += onAdVideoPlayFail;
    ATRewardedVideo.Instance.client.onAdClickEvent += onAdClick;
    ATRewardedVideo.Instance.client.onRewardEvent += onReward;
    ATRewardedVideo.Instance.client.onAdVideoCloseEvent += onAdVideoClosedEvent;

    Dictionary<string,string> jsonmap = new Dictionary<string,string>();
    //If you need to distribute rewards through the developer's server (some advertising platforms support this server incentive), you need to pass the following two keys
    //ATConst.USERID_KEY must be passed, used to identify each user; ATConst.USER_EXTRA_DATA is an optional parameter, which will be transparently transmitted to the developer's server after being passed in.
    jsonmap.Add(ATConst.USERID_KEY, "test_user_id");
    jsonmap.Add(ATConst.USER_EXTRA_DATA, "test_user_extra_data");

    ATRewardedVideo.Instance.loadVideoAd(mPlacementId_rewardvideo_all,jsonmap);
}

Note: See below to learn how Get notified on rewarded video ad events (load success/failure, impression, click, video start/end and reward).

5. Determine whether there is advertising cache

ATRewardedVideo.Instance.hasAdReady(mPlacementId_rewardvideo_all);

6. Display rewarded videos

Compared with displaying native ads, displaying rewarded videos is much simpler. Just call the display api and pass Display ad slot ID as parameter:

public void showVideo()
{        
    Debug.Log ("Developer show video....");
    ATRewardedVideo.Instance.showAd(mPlacementId_rewardvideo_all);
}

When used Scene Function:

public void showVideo()
{
    Debug.Log ("Developer show video....");
    Dictionary<string, string> jsonmap = new Dictionary<string, string>();
    jsonmap.Add(AnyThinkAds.Api.ATConst.SCENARIO, showingScenarioID);
    ATRewardedVideo.Instance.showAd(mPlacementId_rewardvideo_all, jsonmap);    
}

7. Implement multiple rewarded ads Listener

For details of callback information, please see: Callback information description

Note: For Android, all callback events will not be in Unity's main thread

Use the following code to implement multiple listeners

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





Previous
Unity SDK initialization
Next
Fully automatic loading of incentive videos
Last modified: 2025-05-30Powered by