Skip to main content

Interstitials

1.Request Ads

using TradplusSDK.Api;

// traffic group
Dictionary<string, string> customMap = {};
// local custom map, only for Android
Dictionary<string, string> localParams = {};

// set additional parameter extra
TPInterstitialExtra extra = new TPInterstitialExtra();
extra.customMap = customMap;
extra.localParams = localParams;
extra.openAutoLoadCallback = false;

// request ad
TradplusInterstitial.Instance().LoadInterstitialAd("Ad unit ID created on the TP platform", extra);

Parameter Description

unitId:Ad unit ID created on the TradPlus platform
  • The developer needs to fill in correctly, for example, if there are spaces before and after the unitId setting, it will cause the ad to fail to request due to failure to retrieve the configuration.
TPInterstitialExtra:Extra Parameters
  • customMap: Set Segement related attribute parameters
  • localParams:Set local parameters.**Only for Android.**Some ad platforms require special parameters to be set.

2.Checking for Available Ads

  • It is recommended to call this API to check if there are available ads before displaying an ad. Only call the show method if there are ads available.
  • true indicates that there are available ads, false indicates that there are no available ads at the moment.
bool isReady = TradplusInterstitial.Instance().InterstitialAdReady("Ad unit ID created on the TP platform");

3.Entering Ad Scene (Optional)

TradplusInterstitial.Instance().EntryInterstitialAdScenario("Ad unit ID created on the TP platform", "sceneId");

Parameter Description

sceneId :Ad Scene ID
  • Developers can create an ad scene in TradPlus backend. The location is as follows: Application Management - Advertising Scenes.
  • When entering the advertising scene, pass in the sceneId. The sceneId must also be passed in when displaying the ad, otherwise it will affect statistics.

4.Display Ads

// Check if there is an ad before calling show
bool isReady = TradplusInterstitial.Instance().InterstitialAdReady("Ad unit ID created on the TP platform");
if(isReady)
{
// Display Ads
TradplusInterstitial.Instance().ShowInterstitialAd("Ad unit ID created on the TP platform", "sceneId");
}

5.Listen for Callbacks

Parameter Description

Common Callbacks

// Ad loaded successfully
TradplusInterstitial.Instance().OnInterstitialLoaded += OnlLoaded;
// Ad loading failed
TradplusInterstitial.Instance().OnInterstitialLoadFailed += OnLoadFailed;
// Ad displayed successfully
TradplusInterstitial.Instance().OnInterstitialImpression += OnImpression;
// Ad display failed
TradplusInterstitial.Instance().OnInterstitialShowFailed += OnShowFailed;
// Ad clicked
TradplusInterstitial.Instance().OnInterstitialClicked += OnClicked;
// Ad closed
TradplusInterstitial.Instance().OnInterstitialClosed += OnClosed;
// Callback when each layer of waterfall fails to load
TradplusInterstitial.Instance().OnInterstitialOneLayerLoadFailed += OnOneLayerLoadFailed;

void OnlLoaded(string adunit, Dictionary<string, object> adInfo)
{
// Ad loaded successfully
// v1.1.2 optimizes the callback method. One loadAd corresponds to one loaded callback. If it is not called, there will be no callback.
}

void OnLoadFailed(string adunit, Dictionary<string, object> error)
{
// Ad loading failed
}

void OnImpression(string adunit, Dictionary<string, object> adInfo)
{
// Ad display successful
}

void OnShowFailed(string adunit, Dictionary<string, object> adInfo, Dictionary<string, object> error)
{
// Ad display failed
}

void OnClicked(string adunit, Dictionary<string, object> adInfo)
{
// Ad click
}

void OnClosed(string adunit, Dictionary<string, object> adInfo)
{
// Ad close
}

void OnOneLayerLoadFailed(string adunit, Dictionary<string, object> adInfo, Dictionary<string, object> error)
{
// Callback when each layer of waterfall fails to load
}

Ad Source Dimension Callback Listener (Optional)


// Callback returned each time the load method is called
TradplusInterstitial.Instance().OnInterstitialStartLoad += OnStartLoad;
// Bidding start (called once for each bidding ad source)
TradplusInterstitial.Instance().OnInterstitialBiddingStart += OnBiddingStart;
// Bidding end (called once for each bidding ad source)
TradplusInterstitial.Instance().OnInterstitialBiddingEnd += OnBiddingEnd;
// Called when each layer of the waterfall starts loading
TradplusInterstitial.Instance().OnInterstitialOneLayerStartLoad += OnOneLayerStartLoad;
// Called when each layer of the waterfall has successfully loaded
TradplusInterstitial.Instance().OnInterstitialOneLayerLoaded += OnOneLayerLoaded;
// Called when the video playback starts
TradplusInterstitial.Instance().OnInterstitialVideoPlayStart += OnVideoPlayStart;
// Called when the video playback ends
TradplusInterstitial.Instance().OnInterstitialVideoPlayEnd += OnVideoPlayEnd;
// Loading process completed
TradplusInterstitial.Instance().OnInterstitialAllLoaded += OnAllLoaded;
// If this callback is received after calling load, it means that the ad space is still being loaded and cannot trigger a new round of ad loading. Added in V1.0.5
TradplusInterstitial.Instance().OnInterstitialIsLoading += OnAdIsLoading;

void OnStartLoad(string adunit, Dictionary<string, object> adInfo)
{
// The callback returned each time the load method is called
}

void OnBiddingStart(string adunit, Dictionary<string, object> adInfo)
{
// Bidding start (called once for each bidding ad source)
}

void OnBiddingEnd(string adunit, Dictionary<string, object> adInfo, Dictionary<string, object> error)
{
// Bidding end (called once for each bidding ad source)
}

void onAdIsLoading(string unitId)
{
// If this callback is received after calling load, it means that the ad space is still being loaded and cannot trigger a new round of ad loading. Added in V1.0.5
}

void OnOneLayerStartLoad(string adunit, Dictionary<string, object> adInfo)
{
// Called when each layer of the waterfall starts loading
}

void OnOneLayerLoaded(string adunit, Dictionary<string, object> adInfo)
{
// Called when each layer of the waterfall has successfully loaded
}

void OnVideoPlayStart(string adunit, Dictionary<string, object> adInfo)
{
// Called when the video playback starts
}

void OnVideoPlayEnd(string adunit, Dictionary<string, object> adInfo)
{
// Called when the video playback ends
}


void OnAllLoaded(string adunit, bool isSuccess)
{
// Loading process completed
// isSuccess is true if at least one ad source has successfully loaded ads for the ad unit ID
// isSuccess is false if all ad sources have failed to load ads for the ad unit ID
}