Import of splash advertising SDK:
import 'package:anythink_sdk/at_index.dart';
loadSplash() async {
await ATSplashManager.loadSplash(
placementID: 'you placementId',
extraMap: {}
);
}
The default ad loading timeout is 5000 milliseconds. If you need to adjust the ad loading timeout (unit : milliseconds), you need to pass the following parameters,
tolerateTimeout(): int, required, used to set the loading timeout
loadSplash() async {
await ATSplashManager.loadSplash(
placementID: 'you placementId',
extraMap: {
ATSplashManager.tolerateTimeout(): 5000
});
}
Use the following code to determine whether there is ad cache:
splashReady() async {
await ATSplashManager
.splashReady(
placementID: 'you placementId'
)
}
Use the following code to obtain the advertising status (return type: Map) key-value is as follows:
1. isLoading: whether it is loading
2. isReady: whether there is advertising cache
3. adInfo: the current highest priority ad cache information
checkSplashLoadStatus() async {
await ATSplashManager
.checkSplashLoadStatus(
placementID: 'you placementId'
)
}
Get information about all available ads in the current ad slot
getSplashValidAds() async {
await ATSplashManager.getSplashValidAds(
placementID: 'you placementId'
)
}
To display splash ads, just call the display api and pass the display ad slot ID
showSplash() async {
await ATSplashManager
.showSplash(
placementID: 'you placementId'
);
}
When using the scene function When displaying advertisements through this API, the parameters are: advertising slot ID + scene ID (scene ID can be created through the TopOn background)
showSceneSplash() async {
await ATSplashManager
.showSceneSplash(
sceneID: 'you sceneID',
placementID: 'you placementId',
);
}
ATSplashResponse attribute introduction:
SplashStatus: Splash status
placementID: placementID
requestMessage: request information (error message)
extraMap: callback information
isDeeplinkSuccess: isDeeplinkSuccess
isTimeout: Whether the ad has timed out when loading successfully
You can view the sample code below:
splashListen() {
ATListenerManager.splashEventHandler.listen((value) {
switch (value.splashStatus) {
// ad load fail
case SplashStatus.splashDidFailToLoad:
print("flutter splash--splashDidFailToLoad ---- placementID: ${value.placementID} ---- errStr:${value.requestMessage}");
break;
// ad load finish
case SplashStatus.splashDidFinishLoading:
print("flutter splash--splashDidFinishLoading ---- placementID: ${value.placementID} ---- isTimeout:${value.isTimeout}");
break;
// ad load timeout
case SplashStatus.splashDidTimeout:
print("flutter splash--splashDidTimeout ---- placementID: ${value.placementID}");
break;
// ad show success
case SplashStatus.splashDidShowSuccess:
print("flutter splash--splashDidShowSuccess ---- placementID: ${value.placementID} ---- extra:${value.extraMap}");
break;
// ad show fail
case SplashStatus.splashDidShowFailed:
print("flutter splash--splashDidShowFailed ---- placementID: ${value.placementID} ---- errStr:${value.requestMessage}");
break;
// ad clicked
case SplashStatus.splashDidClick:
print("flutter splash--splashDidClick ---- placementID: ${value.placementID} ---- extra:${value.extraMap}");
break;
// DeepLink
case SplashStatus.splashDidDeepLink:
print("flutter splash--splashDidDeepLink ---- placementID: ${value.placementID} ---- extra:${value.extraMap} ---- isDeeplinkSuccess:${value.isDeeplinkSuccess}");
break;
// ad closed
case SplashStatus.splashDidClose:
print("flutter splash--splashDidClose ---- placementID: ${value.placementID} ---- extra:${value.extraMap}");
break;
case SplashStatus.splashUnknown:
print("flutter splash--splashUnknown");
break;
}
});
}
In order to improve the ad loading effect of the first cold start, create an SDK preset policy on the splash ad space Traffic grouping, and then configure waterfall flow in this traffic grouping. It is also recommended that you add a back-up advertising source, and finally export the SDK preset strategy and preset it into the application. For specific access documents, see SDK Preset Strategy Usage Instructions.
Configuration effect: It can realize the SDK preset screen opening strategy, and at the same time realize the hiding function of the screen opening advertising source. That is: this bottom-line advertising source will initiate requests in parallel with the overall waterfall flow under the advertising space. And the user will not necessarily use the bottom-up advertisement in the first request, but will normally use the parallel request of the waterfall flow and the bottom-side advertising source. Can maximize the realization value.
Call before initializing the SDK
setPresetPlacementConfigPath() async {
await ATInitManger.setPresetPlacementConfigPath(
pathStr: "localStrategy"
);
}
1. Android
(1) Create a new directory localStrategy under the src/main/assets directory of the project. The directory naming rules can be customized and used for the following steps.
(2) Place the json file exported from the background into the newly created directory src/main/assets/localStrategy
(3) If you adjust the name of localStrategy, the pathStr parameter passed in setPresetPlacementConfigPath must correspond to the adjusted string
2. iOS
(1) Must put the json file exported from the background into the Bundle where the project is located ([NSBundle mainBundle], the placement path cannot be modified)
(2) The pathStr parameter is not valid for iOS