SplashAds
Precautions
- Do not execute the ad loading method in the
onAdLoadFailed
callback, otherwise it will cause an infinite loop. - Developers can refer to the splash.dart integration in the Demo
Integration steps
1、Request Ads
Map customMap = {};
Map extraMap = TPSplashManager.createSplashExtraMap(customMap: customMap);
TPSplashManager.loadSplashAd("your unitId", extraMap: extraMap);
Parameter Description
unitId:The unitId created in the TradPlus backend
- Developers must fill in the information correctly. For example, if there are spaces before and after the unitId setting, the ad request will fail because the configuration cannot be pulled.
extraMap:Additional parameters
- customMap:Set Traffic Grouping Related attribute parameters
- localParams:Set local parameters. Parameters that need to be set for individual advertising platforms.
2、Check if ads are available
- Developers call this method after listening to the onAdLoaded callback.
- It is recommended that developers call this API to determine whether there are available ads before displaying ads, and then call the show method if there are ads.
- true means there are available ads, false means there are no available ads for the time being
bool isAdReady = TPSplashManager.splashAdReady("unitId");
3、Enter the Ad scene
TPSplashManager.entrySplashAdScenario("unitId", sceneId: "sceneId");
Parameter Description
sceneId :ad scene ID
- Developers can create it in the TradPlus backend at the following location: Application Management - ad Scene.
- For details on how to call, please refer to Description of the timing and purpose of calling advertising scenes。
- When entering the advertising scene, pass in the sceneId. When displaying the advertisement, you also need to pass in the sceneId, otherwise it will affect the statistics.
4、Display ads
Flutter plugin version v1.0.4+, iOS v8.5.0+, Android v8.8.0.1+
Splash screen ads support mixed use of native ads, and developers can pass in custom native template names through optional parameters.
- Android
//layoutName Optional parameters (v1.0.4+)
return TPSplashViewWidget(unitId,layoutName:"layoutName");
- iOS
//Pass in sceneId when displaying ads(v1.1.3+)
TPSplashManager.showSplashAd(unitId,sceneId: "splash_sceneId");
//className Optional parameters (v1.0.4+)
TPSplashManager.showSplashAd(unitId,className: "className",sceneId: "splash_sceneId");
5、Listening callback
Parameter Description
- adInfo:For more information, please refer to Callback Information Description。
- error:Error messages about ad request failure and ad display failure. For details, please refer to Error code and error message description
Basic callback
addListener() {
listener = TPSplashAdListener(
// Ad loading successful
// V1.1.2 callback mechanism optimization, developers will call load once to get a
onAdLoaded: (adUnitId, adInfo) {
},
// Ad loading failed
onAdLoadFailed: (adUnitId, error) {
},
// Ad display
onAdImpression: (adUnitId, adInfo) {
},
// Ad display failed
onAdShowFailed: (adUnitId, adInfo, error) {
},
//Ad clicked
onAdClicked: (adUnitId, adInfo) {
},
//Ad closed
onAdClosed: (adUnitId, adInfo) {
},
// Ad source loading failed
oneLayerLoadFailed: (adUnitId, adInfo, error) {
},
)
TPSplashManager.setSplashListener(listener!);
}
other callback(optional)
...
onAdStartLoad: (adUnitId, adInfo) {
// The callback returned each time the load method is called
},
onBiddingStart: (adUnitId, adInfo) {
// Bidding starts loading
},
onBiddingEnd: (adUnitId, adInfo, error) {
// Bidding loading is finished
// Configure bidding ad source to listen
// During testing, get the reason why bidding loading failed through error
},
oneLayerStartLoad: (adUnitId, adInfo) {
//Callback triggered before each layer of waterfall initiates a request to the third-party advertising source
},
oneLayerLoaded: (adUnitId, adInfo) {
// Configure multiple ad sources in the background, and each ad source will be called back once after loading successfully
},
onAdAllLoaded: (adUnitId, isSuccess) {
// Status of the ad slot
// isSuccess returns true, indicating that an ad source has been successfully loaded for this request
// isSuccess returns false, indicating that all ad sources under the ad slot adUnitId have failed to load for this request
},
onAdIsLoading: (adUnitId) {
// New in V1.0.5
// If this callback is received after calling load, it means that the ad slot is still in the loading state and cannot trigger a new round of ad loading.
}
onZoomOutStart: (String adUnitId, Map adInfo)
{
//Show the finishing touch
}
onZoomOutEnd: (String adUnitId, Map adInfo)
{
//close the finishing touch
}
onSkip: (String adUnitId, Map adInfo)
{
//skip
}
...
Download Kuaishou, ByteDance support (optional) (only supported by Android)
...
onDownloadStart: (adUnitId, totalBytes, currBytes, fileName, appName) {
// Start download callback
// totalBytes: total file size (unit: bytes)
// currBytes: currently downloaded size (unit: bytes)
// fileName: file name
// appName: application name corresponding to the file
},
onDownloadUpdate: (adUnitId, totalBytes, currBytes, fileName, appName, progress) {
// Download progress update callback
// progress: download progress
},
onDownloadPause: (adUnitId, totalBytes, currBytes, fileName, appName) {
// Pause download callback
},
onDownloadFinish: (adUnitId, totalBytes, currBytes, fileName, appName) {
// Download completed callback
},
onDownloadFail: (adUnitId, totalBytes, currBytes, fileName, appName) {
// Download failed callback
},
onInstall: (adUnitId, totalBytes, currBytes, fileName, appName) {
//Apk installation completed callback
}
...