Menu

Fully automatic loading of interstitial ads

The Auto Load mode is a one-stop request management solution launched by TopOn, which can intelligently determine the preloading and caching timing of the next ad based on the user's usage status and ad consumption progress at multiple nodes. On the basis of meeting 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 being loaded or loading not being smooth. With the Auto Load solution, developers can avoid repetitive and cumbersome manual intervention in request schemes, with immediate and noticeable efficiency improvements.

1. Integration Process Suggestions

  1. When the app starts, load the ad by calling ATInterstitialAutoAd#addAutoLoadAdPlacementID.
  2. At the position where you need to display an ad, check whether it can be shown via ATInterstitialAutoAd#autoLoadInterstitialAdReadyForPlacementID.
  3. If you need to use Ad Scenarios to differentiate data for different business scenarios, refer to the sample code for details.

Note: If a placement is set to Auto Load, do not call ATInterstitialAd#loadInterstitialAd (regular interstitial ad) to load ads.

2. API Description

ATInterstitialAutoAd:

API Parameters Description
addAutoLoadAdPlacementID string placementIDList Set the placements that need to be auto-loaded
removeAutoLoadAdPlacementID string placementId Remove the placements that do not need to be auto-loaded
setListener ATRewardedVideoListener listener (Deprecated after version 5.9.51) Set listener
autoLoadInterstitialAdReadyForPlacementID string placementid Check if there is an ad cache
showAutoAd string mapJson Show an ad
showAutoAd string placementid, Dictionary extra Show an ad using the scenario feature
entryAutoAdScenarioWithPlacementID string placementid, string scenarioID Set entry into a displayable ad scenario

Use the following code to set up Auto Load for interstitial ads:

java Copy
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);
}

4. Check if There Is an Ad Cache

java Copy
bool isReady = ATInterstitialAutoAd.Instance.autoLoadInterstitialAdReadyForPlacementID(mPlacementId_interstitial_all);
java Copy
public void showAutoAd()
{
    ATInterstitialAutoAd.Instance.showAutoAd(mPlacementId_interstitial_all);
}

When using the scenario feature:

java Copy
public void showAutoAd()
{
        // Set entry into scenario
    ATInterstitialAutoAd.Instance.entryAutoAdScenarioWithPlacementID(mPlacementId_interstitial_all, showingScenario);
    Dictionary<string string=""> jsonmap = new Dictionary<string string="">();
    jsonmap.Add(AnyThinkAds.Api.ATConst.SCENARIO, showingScenario);
    ATInterstitialAutoAd.Instance.showAutoAd(mPlacementId_interstitial_all,jsonmap);
}</string></string>

6. Implement Multiple Listeners for Auto Load Interstitial Ads

For callback information details, please see: Callback Information Description

Use the following code to implement multiple listeners:

java Copy
        // Ad loading succeeded
        ATInterstitialAutoAd.Instance.client.onAdLoadEvent += onAdLoad; 
        // Ad loading failed
        ATInterstitialAutoAd.Instance.client.onAdLoadFailureEvent += onAdLoadFail;
        // Ad displayed (this callback can be relied on for impression statistics)
        ATInterstitialAutoAd.Instance.client.onAdShowEvent += onShow;
        // Ad clicked
        ATInterstitialAutoAd.Instance.client.onAdClickEvent += onAdClick;
        // Ad dismissed
        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 parameter definitions are as follows in the code (Note: The method name can follow the code below or be a custom method name, but the parameters must be consistent.):

java Copy
    // sender is the ad type object, erg is the returned information
    // Ad loading succeeded
    public void onAdLoad(object sender,ATAdEventArgs erg)
    {
        Debug.Log("Developer callback onInterstitialAdLoad :" + erg.placementId);
    }

    // Ad loading failed
    public void onAdLoadFail(object sender,ATAdErrorEventArgs erg )
    {
        Debug.Log("Developer callback onInterstitialAdLoadFail :" + erg.placementId + "--erg.code:" + code + "--msg:" + erg.message);
    }

    // Ad display succeeded
    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 dismissed
    public void onAdClose(object sender,ATAdEventArgs erg)
    {
        Debug.Log("Developer callback onInterstitialAdClose :" + erg.placementId);
    }

    // Ad video playback started (some platforms have this callback)
    public void startVideoPlayback(object sender,ATAdEventArgs erg)
    {
        Debug.Log("Developer callback onInterstitialAdStartPlayingVideo :" + erg.placementId);
    }

    // Ad video playback ended (some ad networks have this callback)
    public void endVideoPlayback(object sender,ATAdEventArgs erg)
    {
        Debug.Log("Developer callback onInterstitialAdEndPlayingVideo :" + erg.placementId);
    }

    // Ad video playback failed (some ad networks have this callback)
    public void failVideoPlayback(object sender,ATAdEventArgs erg)
    {
        Debug.Log("Developer callback onInterstitialAdFailedToPlayVideo :" + erg.placementId + "--code:" + erg.code + "--msg:" + erg.message);
    }
Previous
Interstitial ad
Next
Banner Ad
Last modified: 2026-07-03Powered by