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.
Note: If the advertising space is set to full For automatic loading, can no longer call ATRewardedVideo#loadVideoAd(Normal rewarded video ) to load ads
ATRewardedAutoVideo:
API | Parameters | Description |
---|---|---|
addAutoLoadAdPlacementID | string[] placementIDList | Set the ad slots that need to be loaded automatically |
removeAutoLoadAdPlacementID | string placementId | Remove ad slots that do not require automatic loading |
setAutoLocalExtra | string placementId, string mapJson | Set local parameters for the ad slot |
setListener | ATRewardedVideoListener 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 |
autoLoadRewardedVideoReadyForPlacementID | string placementid | Determine whether there is an ad cache |
checkAdStatus | string placementid | Get 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) |
getAutoValidAdCaches | string placementid | Get loading successfully All ad cache information (JSON string) (refer to ATCallbackInfo description) |
showAutoAd | string mapJson | show ads |
showAutoAd | string placementid,Dictionary<string,string> extra | Use scene function to display ads more |
entryAutoAdScenarioWithPlacementID | string placementid, string scenarioID | Set up to enter the displayable advertising scenario |
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) .
bool isReady = ATRewardedAutoVideo.Instance.autoLoadRewardedVideoReadyForPlacementID(mPlacementId_rewardvideo_all);
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);
}
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()));
}