Interstitial ads are an aggregation of image interstitial ads and video interstitial ads from other third-party advertising platforms. Both ad types can use the API of ATAdManager to load and play ads. Currently, two integration methods are supported, the details are as follows:
Mode (choose one) | Description |
---|---|
Manual request mode | You choose the appropriate time to load the ad through the API , please refer to the integration suggestions below the document for details |
Fully automatic loading mode | TopOn's one-stop request maintenance solution can automatically determine the preloading and caching timing of the next advertisement based on the user's usage status and ad consumption progress to achieve better results. Loading effect, see for details: Fully automatic loading mode for interstitial ads |
false: Re-execute ATInterstitialAd#loadInterstitialAd to load ads
true: Execute ATInterstitialAd#showInterstitialAd to display the advertisement, and then execute ATInterstitialAd#loadInterstitialAd in the callback of onInterstitialAdClose to preload the next advertisement (loadInterstitialAd can be called directly in the callback of onInterstitialAdClose without going through the judgment of hasInterstitialAdReady, which helps to improve priority comparison. High display volume of advertising sources.)
3. Ad preloading:
Insert After the on-screen ad is displayed, there is no need to judge ATInterstitialAd#hasInterstitialAdReady in the callback of onInterstitialAdShow (v5.8.10 and later) or onInterstitialAdClose (less than v.5.8.10). Directly call ATInterstitialAd#loadInterstitialAd for preloading (which helps to improve the priority). The amount of impressions of the advertising source)
You can refer to Automatically request ads to turn on automatic request for ads (if preloading after display above has been implemented, there is no need to turn it on)
4. If you need to use advertising scenarios to distinguish data from different business scenarios, please refer to the sample code
ATInterstitialAd:
API | Parameters | Description |
---|---|---|
loadInterstitialAd | string placementid, Dictionary<string,string> extra | Loading ads |
setListener | ATInterstitialAdListener listener | Set listening Callback interface (Abandoned after version 5.9.51) For details on how to set the listener, please refer to: Interstitial ad event setting instructions |
hasInterstitialAdReady | string placementid | Determine whether there is ad cache |
showInterstitialAd | string placementid,Dictionary<string,string> extra | Display advertising |
entryScenarioWithPlacementID | string placementId, string scenarioID | Set to enter the displayable advertising scene |
Use the following Code to load interstitial ads
public void loadInterstitialAd()
{
ATInterstitialAd.Instance.client.onAdLoadEvent += onAdLoad;
ATInterstitialAd.Instance.client.onAdLoadFailureEvent += onAdLoadFail;
ATInterstitialAd.Instance.client.onAdShowEvent += onShow;
ATInterstitialAd.Instance.client.onAdClickEvent += onAdClick;
ATInterstitialAd.Instance.client.onAdCloseEvent += onAdClose;
ATInterstitialAd.Instance.client.onAdShowFailureEvent += onAdShowFail;
ATInterstitialAd.Instance.client.onAdVideoStartEvent += startVideoPlayback;
ATInterstitialAd.Instance.client.onAdVideoEndEvent += endVideoPlayback;
ATInterstitialAd.Instance.client.onAdVideoFailureEvent += failVideoPlayback;
Dictionary<string,string> jsonmap = new Dictionary<string,string>();
ATInterstitialAd.Instance.loadInterstitialAd(mPlacementId_interstitial_all, jsonmap);
}
Note: See below to learn how to get notified about interstitial ad events (load success/failure, impression, click, video start end).
ATInterstitialAd.Instance.hasInterstitialAdReady(mPlacementId_interstitial_all);
Same as rewarded videos, interstitial ads only need to call the display api and pass the display ad slot ID as a parameter :
public void showInterstitialAd()
{
ATInterstitialAd.Instance.showInterstitialAd(mPlacementId_interstitial_all);
}
When using Scene Function:
public void showInterstitialAd()
{
Dictionary<string, string> jsonmap = new Dictionary<string, string>();
jsonmap.Add(AnyThinkAds.Api.ATConst.SCENARIO, showingScenarioID);
ATInterstitialAd.Instance.showInterstitialAd(mPlacementId_interstitial_all, jsonmap);
}
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
//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 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);
}
//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);
}
//The advertising video starts playing. Some platforms have this callback.
public void startVideoPlayback(object sender,ATAdEventArgs erg)
{
Debug.Log("Developer callback onInterstitialAdStartPlayingVideo :" + erg.placementId);
}
//Ad display failed
public void failVideoPlayback(object sender,ATAdEventArgs erg)
{
Debug.Log("Developer callback onInterstitialAdFailedToShow :" + erg.placementId);
}