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 mode | You 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 mode | TopOn'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 |
ATRewardedVideo:
API | Parameters | Description |
---|---|---|
loadVideoAd | string placementid, Dictionary<string,string> extra | |
setListener< /td> | ATRewardedVideoListener listener | Set 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 |
hasAdReady | string placementid | Determine whether there is Ad cache |
showAd | string placementid | Display ads |
showAd | string placementid,Dictionary<string,string> extra | Use the scene function to display ads more |
entryScenarioWithPlacementID | string placementid, string scenarioID | Settings can be entered Display advertising scene |
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).
ATRewardedVideo.Instance.hasAdReady(mPlacementId_rewardvideo_all);
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);
}
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;