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.
Note: If a placement is set to Auto Load, do not call ATInterstitialAd#loadInterstitialAd (regular interstitial ad) to load ads.
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:
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<string string=""> jsonmap = new Dictionary<string string="">();
jsonmap.Add(AnyThinkAds.Api.ATConst.SCENARIO, showingScenario);
ATInterstitialAutoAd.Instance.showAutoAd(mPlacementId_interstitial_all,jsonmap);
}</string></string>
For callback information details, please see: Callback Information Description
Use the following code to implement multiple listeners:
// 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.):
// 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);
}