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.
Note: If an ad placement is set to Auto Load, do NOT call ATInterstitialAd#loadInterstitialAd (regular interstitial ad) for ad loading.
ATInterstitialAutoAd:
| 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 |
| setListener | ATRewardedVideoListener listener | (Deprecated after version 5.9.51) For how to set listeners, see: Interstitial Ad Event Settings |
| autoLoadInterstitialAdReadyForPlacementID | string placementid | Check if there is a cached ad |
| checkAdStatus | string placementid | (Added in v5.7.03) 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 | (Added in v5.7.54) 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 |
Use the following code to set up auto-loading interstitial ads:
public void addAutoLoadAdPlacementID()
{
ATInterstitialAutoAd.Instance.client.onAdLoadEvent += onAdLoad;
ATInterstitialAutoAd.Instance.client.onAdLoadFailureEvent += onAdLoadFail;
ATInterstitialAutoAd.Instance.client.onAdShowEvent += onShow;
ATInterstitialAutoAd.Instance.client.onAdClickEvent += onAdClick;
ATInterstitialAutoAd.Instance.client.onAdCloseEvent += onAdClose;
ATInterstitialAutoAd.Instance.client.onAdShowFailureEvent += onAdShowFail;
ATInterstitialAutoAd.Instance.client.onAdVideoStartEvent += startVideoPlayback;
ATInterstitialAutoAd.Instance.client.onAdVideoEndEvent += endVideoPlayback;
ATInterstitialAutoAd.Instance.client.onAdVideoFailureEvent += failVideoPlayback;
string[] jsonList = {mPlacementId_interstitial_all};
ATInterstitialAutoAd.Instance.addAutoLoadAdPlacementID(jsonList);
}
bool isReady = ATInterstitialAutoAd.Instance.autoLoadInterstitialAdReadyForPlacementID(mPlacementId_interstitial_all);
public void showAutoAd()
{
ATInterstitialAutoAd.Instance.showAutoAd(mPlacementId_interstitial_all);
}
When using the scenario feature:
public void showAutoAd()
{
// Set entry into scenario
ATInterstitialAutoAd.Instance.entryAutoAdScenarioWithPlacementID(mPlacementId_interstitial_all, showingScenario);
Dictionary jsonmap = new Dictionary();
jsonmap.Add(AnyThinkAds.Api.ATConst.SCENARIO, showingScenario);
ATInterstitialAutoAd.Instance.showAutoAd(mPlacementId_interstitial_all,jsonmap);
}
For callback info details, see: Callback Info Description
Use the following code to implement multiple listeners:
// Ad loaded successfully
ATInterstitialAutoAd.Instance.client.onAdLoadEvent += onAdLoad;
// Ad load failed
ATInterstitialAutoAd.Instance.client.onAdLoadFailureEvent += onAdLoadFail;
// Ad displayed (can rely on this callback for impression statistics)
ATInterstitialAutoAd.Instance.client.onAdShowEvent += onShow;
// Ad clicked
ATInterstitialAutoAd.Instance.client.onAdClickEvent += onAdClick;
// Ad closed
ATInterstitialAutoAd.Instance.client.onAdCloseEvent += onAdClose;
// Ad display failed
ATInterstitialAutoAd.Instance.client.onAdShowFailureEvent += onAdShowFail;
// Video ad playback started
ATInterstitialAutoAd.Instance.client.onAdVideoStartEvent += startVideoPlayback;
// Video ad playback ended
ATInterstitialAutoAd.Instance.client.onAdVideoEndEvent += endVideoPlayback;
// Video ad playback failed
ATInterstitialAutoAd.Instance.client.onAdVideoFailureEvent += failVideoPlayback;
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):
//sender is the ad type object, erg is the returned info
// Ad loaded successfully
public void onAdLoad(object sender,ATAdEventArgs erg)
{
Debug.Log("Developer callback onInterstitialAdLoad :" + erg.placementId);
}
// Ad load failed
public void onAdLoadFail(object sender,ATAdErrorEventArgs erg )
{
Debug.Log("Developer callback onInterstitialAdLoadFail :" + erg.placementId + "--erg.code:" + code + "--msg:" + erg.message);
}
// Ad displayed successfully
public void onShow(object sender,ATAdEventArgs erg)
{
Debug.Log("Developer callback onInterstitialAdShow :" +erg. placementId);
}
// Ad clicked
public void onAdClick(object sender,ATAdEventArgs erg)
{
Debug.Log("Developer callback onInterstitialAdClick :" + erg.placementId);
}
// Ad closed
public void onAdClose(object sender,ATAdEventArgs erg)
{
Debug.Log("Developer callback onInterstitialAdClose :" + erg.placementId);
}
// Video ad playback started, some platforms have this callback
public void startVideoPlayback(object sender,ATAdEventArgs erg)
{
Debug.Log("Developer callback onInterstitialAdStartPlayingVideo :" + erg.placementId);
}
// Video ad playback ended, some ad platforms have this callback
public void endVideoPlayback(object sender,ATAdEventArgs erg)
{
Debug.Log("Developer callback onInterstitialAdEndPlayingVideo :" + erg.placementId);
}
// Video ad playback failed, some ad platforms have this callback
public void failVideoPlayback(object sender,ATAdEventArgs erg)
{
Debug.Log("Developer callback onInterstitialAdFailedToPlayVideo :" + erg.placementId + "--code:" + erg.code + "--msg:" + erg.message);
}
You can implement a class that implements the ATRewardedAutoVideo Listener interface to get notified about rewarded video ad events: (Note: For Android, all callback methods are not on the Unity main thread)
class InterstitalCallback : ATInterstitialAdListener
{
// Ad clicked
public void onInterstitialAdClick(string placementId, ATCallbackInfo callbackInfo)
{
Debug.Log("Developer callback onInterstitialAdClick :" + placementId);
}
// Ad closed
public void onInterstitialAdClose(string placementId, ATCallbackInfo callbackInfo)
{
Debug.Log("Developer callback onInterstitialAdClose :" + placementId);
}
// Video ad playback ended, some ad platforms have this callback
public void onInterstitialAdEndPlayingVideo(string placementId, ATCallbackInfo callbackInfo)
{
Debug.Log("Developer callback onInterstitialAdEndPlayingVideo :" + placementId);
}
// Video ad playback failed, some ad platforms have this callback
public void onInterstitialAdFailedToPlayVideo(string placementId, string code, string message)
{
Debug.Log("Developer callback onInterstitialAdFailedToPlayVideo :" + placementId + "--code:" + code + "--msg:" + message);
}
// Ad loaded successfully
public void onInterstitialAdLoad(string placementId)
{
Debug.Log("Developer callback onInterstitialAdLoad :" + placementId);
}
// Ad load failed
public void onInterstitialAdLoadFail(string placementId, string code, string message)
{
Debug.Log("Developer callback onInterstitialAdLoadFail :" + placementId + "--code:" + code + "--msg:" + message);
}
// Ad displayed successfully
public void onInterstitialAdShow(string placementId, ATCallbackInfo callbackInfo)
{
Debug.Log("Developer callback onInterstitialAdShow :" + placementId);
}
// Video ad playback started, some ad platforms have this callback
public void onInterstitialAdStartPlayingVideo(string placementId, ATCallbackInfo callbackInfo)
{
Debug.Log("Developer callback onInterstitialAdStartPlayingVideo :" + placementId);
}
// Ad display failed
public void onInterstitialAdFailedToShow(string placementId)
{
Debug.Log("Developer callback onInterstitialAdFailedToShow :" + placementId);
}
// 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------");
}
}
Note: The code snippets in this section are from the interstitialScenes demo project in our Demo.