Menu

Fully automatic loading of interstitial ads


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.

1. Access process suggestions

  1. Load ads by calling ATInterstitialAutoAd#addAutoLoadAdPlacementID when starting the application
  2. Use ATInterstitialAutoAd#autoLoadInterstitialAdReadyForPlacementID to determine whether it can be displayed where the advertisement needs to be displayed
  3. If you need to use Advertising scenariosDistinguish the data of different business scenarios, please refer to the sample code for details

Note: If the advertising space is set to fully automatic loading, Don't call ATInterstitialAd#loadInterstitialAd (Normal interstitial ad) for advertising Loading

2. API Description

ATInterstitialAutoAd:

APIParametersDescription
addAutoLoadAdPlacementIDstring[] placementIDListSet ad slots that need to be loaded automatically
removeAutoLoadAdPlacementIDstring placementIdRemove ad slots that do not require automatic loading
setAutoLocalExtrastring placementId, string mapJsonSet additional parameters for the ad slot
setListenerATRewardedVideoListener listener (Abandoned after version 5.9.51) For details on how to set up a listener, please refer to: Insert screen Ad event setting instructions**
autoLoadInterstitialAdReadyForPlacementIDstring placementidDetermine whether there is an ad cache
showAutoAdstring mapJsonshow ads
showAutoAdstring placementid, Dictionary<string,string> extraUse scene function to display ads more
entryAutoAdScenarioWithPlacementIDstring placementid, string scenarioIDSet to enter the displayable advertising scenario

3. Set local parameters

4. Load ads

Use the following code to set up fully automatic loading of 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);
}

5. Determine whether there is advertising cache

bool isReady = ATInterstitialAutoAd.Instance.autoLoadInterstitialAdReadyForPlacementID(mPlacementId_interstitial_all);

6. Display ads

public void showAutoAd()
{
    ATInterstitialAutoAd.Instance.showAutoAd(mPlacementId_interstitial_all);
}

When using the Scene function:

public void showAutoAd()
{
        //Set up the scene
    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);
}

7. Implement fully automatic loading of multiple listeners for interstitial ads

Please see the callback information details: Callback information description

Use the following code to implement 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;
        //广告被关闭
        ATRewardedAutoVideo.Instance.client.onAdVideoCloseEvent += onAdVideoClosedEvent;

The method definition parameters are as follows (Note: The method name can Refer to the following code or customize the method name, but the parameters must be consistent)

    //sender is the advertising type object, erg is the return information
    //Advertisement loaded successfully
    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);
    }

    //Advertisement 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);
    }

    //Ads are turned off
    public void onAdClose(object sender,ATAdEventArgs erg)
    {
        Debug.Log("Developer callback onInterstitialAdClose :" + erg.placementId);
    }

    //The advertising video starts playing. Some platforms have this callback.
​
    public void startVideoPlayback(object sender,ATAdEventArgs erg)
    {
        Debug.Log("Developer callback onInterstitialAdStartPlayingVideo :" + erg.placementId);
    }

    //The advertising video ends. Some advertising platforms have this callback.
    public void endVideoPlayback(object sender,ATAdEventArgs erg)
    {
        Debug.Log("Developer callback onInterstitialAdEndPlayingVideo :" + erg.placementId);
    }

    //Ad video playback failed, some advertising platforms 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: 2025-05-30Powered by