SplashAds
Prerequisites
- Android V10.0.1.1 / iOS 9.7.0 (Unity plugin V1.3.3) supports splash ad integration.
- When using multiple caches, developers need to control the consecutive display.
- Developers need to configure the splash activity in the manifest file.
<activity
android:name="com.tradplus.unity.plugin.splash.TPSplashShowActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
1. Request Ads
using TradplusSDK.Api;
// Traffic segmentation
Dictionary<string, string> customMap = {};
// Local custom Map, Android only
Dictionary<string, string> localParams = {};
// Set additional parameter extra
TPSplashExtra extra = new TPSplashExtra();
extra.customMap = customMap;
extra.localParams = localParams;
extra.openAutoLoadCallback = false;
// Request ads
TradplusSplash.Instance().LoadSplashAd("Ad unit ID created on TP platform", extra);
Parameter Description
unitId: Ad unit ID created on TradPlus backend
- Developers need to fill in correctly, for example: if there are spaces before and after unitId, the ad request will fail because the configuration cannot be retrieved.
TPSplashExtra: Additional Parameters
- customMap: Set Segement related attribute parameters
- localParams: Set local parameters. Android only. Some ad platforms require specific parameters to be set.
2. Check 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 = TradplusSplash.Instance().SplashAdReady("Ad unit ID created on TP platform");
3. Enter Ad Scene
TradplusSplash.Instance().EntrySplashAdScenario("Ad unit ID created on TP platform", "sceneId");
Parameter Description
sceneId: Ad scene ID (recommended)
- Developers can create it on the TradPlus backend, located in: App Management - Ad Scenario.
- When entering the ad scene, pass in the sceneId, and when displaying the ad, sceneId should also be passed in, otherwise it will affect statistics.
4. Display Ads
// Check if there is an ad before calling show
bool isReady = TradplusSplash.Instance().SplashAdReady("Ad unit ID created on TP platform");
if(isReady)
{
// Display the ad
TradplusSplash.Instance().ShowSplashAd("Ad unit ID created on TP platform", "sceneId");
}
5. Listen for Callbacks
Parameter Description
-
adInfo: Ad unit ID, third-party ad platform, eCPM, and other information. Please refer to Android Callback Information and iOS Callback Information for details.
-
error: Error information for ad request failure and ad display failure. Please refer to Error Code and Error Information for details.
Common Callbacks
// Ad loaded successfully
TradplusSplash.Instance().OnSplashLoaded += OnlLoaded;
// Ad loading failed
TradplusSplash.Instance().OnSplashLoadFailed += OnLoadFailed;
// Ad displayed successfully
TradplusSplash.Instance().OnSplashImpression += OnImpression;
// Ad display failed
TradplusSplash.Instance().OnSplashShowFailed += OnShowFailed;
// Ad clicked
TradplusSplash.Instance().OnSplashClicked += OnClicked;
// Ad closed
TradplusSplash.Instance().OnSplashClosed += OnClosed;
// Callback when each layer of waterfall fails to load
TradplusSplash.Instance().OnSplashOneLayerLoadFailed += OnOneLayerLoadFailed;
void OnlLoaded(string adunit, Dictionary<string, object> adInfo)
{
// Ad loaded successfully
// One loaded callback for each loadAd call, it will not be called if not invoked.
}
void OnLoadFailed(string adunit, Dictionary<string, object> error)
{
// Ad loading failed
}
void OnImpression(string adunit, Dictionary<string, object> adInfo)
{
// Ad displayed successfully
}
void OnShowFailed(string adunit, Dictionary<string, object> adInfo, Dictionary<string, object> error)
{
// Ad display failed
}
void OnClicked(string adunit, Dictionary<string, object> adInfo)
{
// Ad clicked
}
void OnClosed(string adunit, Dictionary<string, object> adInfo)
{
// Ad closed
}
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 Listeners (optional)
// Callback returned each time the load method is called
TradplusSplash.Instance().OnSplashStartLoad += OnStartLoad;
// Bidding starts (callback once for each bidding ad source)
TradplusSplash.Instance().OnSplashBiddingStart += OnBiddingStart;
// Bidding loading ends (callback once for each bidding ad source)
TradplusSplash.Instance().OnSplashBiddingEnd += OnBiddingEnd;
// Callback when each layer of waterfall starts loading
TradplusSplash.Instance().OnSplashOneLayerStartLoad += OnOneLayerStartLoad;
// Callback when each layer of waterfall is loaded successfully
TradplusSplash.Instance().OnSplashOneLayerLoaded += OnOneLayerLoaded;
// Video playback starts
TradplusSplash.Instance().OnSplashVideoPlayStart += OnVideoPlayStart;
// Video playback ends
TradplusSplash.Instance().OnSplashVideoPlayEnd += OnVideoPlayEnd;
// Load process ends
TradplusSplash.Instance().OnSplashAllLoaded += OnAllLoaded;
// If you receive this callback after calling load, it means that the ad unit is still in the loading state and cannot trigger a new round of ad loading.
TradplusSplash.Instance().OnSplashIsLoading += OnAdIsLoading;
void OnStartLoad(string adunit, Dictionary<string, object> adInfo)
{
// Callback returned each time the load method is called
}
void OnBiddingStart(string adunit, Dictionary<string, object> adInfo)
{
// Bidding starts (callback once for each bidding ad source)
}
void OnBiddingEnd(string adunit, Dictionary<string, object> adInfo, Dictionary<string, object> error)
{
// Callback when bidding loading ends (callback once for each bidding ad source)
}
void onAdIsLoading(string unitId)
{
// If you receive this callback after calling load, it means that the ad unit is still in the loading state and cannot trigger a new round of ad loading.
}
void OnOneLayerStartLoad(string adunit, Dictionary<string, object> adInfo)
{
// Callback when each layer of waterfall starts loading
}
void OnOneLayerLoaded(string adunit, Dictionary<string, object> adInfo)
{
// Callback when each layer of waterfall is loaded successfully
}
void OnVideoPlayStart(string adunit, Dictionary<string, object> adInfo)
{
// Callback when video playback starts
}
void OnVideoPlayEnd(string adunit, Dictionary<string, object> adInfo)
{
// Callback when video playback ends
}
void OnAllLoaded(string adunit, bool isSuccess)
{
// Callback when the load process ends
// isSuccess returns true, indicating that there are successful ad sources for this request
// isSuccess returns false, indicating that all ad sources for adUnitId under this request have failed to load
}