Importing the Interstitial Ad SDK:
import 'package:anythink_sdk/at_index.dart';
Use the following code to load an Interstitial ad
loadInterstitialAd() async {
ATinterstitialManager
.loadInterstitialAd(placementID: 'you placementId', extraMap: {});
}
Only for the Sigmob platform, use Sigmob's rewarded video ad source as an interstitial (Optional. Note: After enabling, the Sigmob interstitial Ad Source in the Taku dashboard must be configured with Sigmob's rewarded video parameters)
loadInterstitialAd() async {
ATinterstitialManager
.loadInterstitialAd(placementID: 'you placementId', extraMap: {
ATinterstitialManager.UseRewardedVideoAsInterstitialKey(): true
});
}
Use the following code to check if there is a cached ad:
_hasInterAdReady() async {
await ATinterstitialManager
.hasInterstitialAdReady(
placementID: 'you placementId',
)
.then((value) {
print('flutter Interstitial ad video cache $value');
});
}
Use the following code to get the ad status (return value type is Map). The key-value pairs are as follows:
isLoading: Whether it is loading
isReady: Whether there is a cached ad
adInfo: The highest-priority cached ad info
_checkInterAdStatus() async {
await ATinterstitialManager
.CheckInterstitialLoadStatus(
placementID: 'b5bacad80a0fb1',
)
.then((value) {
print('flutter Interstitial ad video status $value');
});
}
Get information about all available ads under the current ad placement
getInterstitialValidAds() async {
await ATinterstitialManager
.getInterstitialValidAds(
placementID: Configuration.interstitialPlacementID,
)
.then((value) {
print('flutter Interstitial ad video status $value');
});
}
entryInterstitialScenario(String placementID, String sceneID) async {
ATInterstitialManager.entryInterstitialScenario(
placementID: 'you placementId',
sceneID: 'you sceneID',
);
}
To display an interstitial ad, simply call the show API and pass the ad placement ID.
_showInterAd() async {
ATinterstitialManager
.showInterstitialAd(
placementID: 'you placementId',
);
}
When using the scenario feature, display the ad through this API. Parameters: Ad Placement ID + Scenario ID (the Scenario ID can be created in the Taku dashboard)
showSceneInterstitialAd() async {
ATinterstitialManager
.showSceneInterstitialAd(
placementID: 'you placementId',
sceneID: 'you sceneID',
);
}
ATInterstitialResponse property description:
InterstitialStatus: Interstitial ad status
placementID: placementID
requestMessage: Request info (error message)
extraMap: Callback Info
isDeeplinkSuccess: isDeeplinkSuccess
An example notification for interstitial ad events is as follows:
_interListen() {
ATListenerManager.interstitialEventHandler.listen((value) {
switch (value.interstatus) {
// Ad load failed
case InterstitialStatus.interstitialAdFailToLoadAD:
print("flutter interstitialAdFailToLoadAD ---- placementID: ${value.placementID} ---- errStr:${value.requestMessage}");
break;
// Ad loaded successfully
case InterstitialStatus.interstitialAdDidFinishLoading:
print("flutter interstitialAdDidFinishLoading ---- placementID: ${value.placementID}");
break;
// Ad video playback started, some platforms have this callback
case InterstitialStatus.interstitialAdDidStartPlaying:
print("flutter interstitialAdDidStartPlaying ---- placementID: ${value.placementID} ---- extra:${value.extraMap}");
break;
// Ad video playback ended, some ad platforms have this callback
case InterstitialStatus.interstitialAdDidEndPlaying:
print("flutter interstitialAdDidEndPlaying ---- placementID: ${value.placementID} ---- extra:${value.extraMap}");
break;
// Ad video playback failed, some ad platforms have this callback
case InterstitialStatus.interstitialDidFailToPlayVideo:
print("flutter interstitialDidFailToPlayVideo ---- placementID: ${value.placementID} ---- errStr:${value.requestMessage}");
break;
// Ad displayed successfully
case InterstitialStatus.interstitialDidShowSucceed:
print("flutter interstitialDidShowSucceed ---- placementID: ${value.placementID} ---- extra:${value.extraMap}");
break;
// Ad display failed
case InterstitialStatus.interstitialFailedToShow:
print("flutter interstitialFailedToShow ---- placementID: ${value.placementID} ---- errStr:${value.requestMessage}");
break;
// Ad clicked
case InterstitialStatus.interstitialAdDidClick:
print("flutter interstitialAdDidClick ---- placementID: ${value.placementID} ---- extra:${value.extraMap}");
break;
// Deeplink
case InterstitialStatus.interstitialAdDidDeepLink:
print("flutter interstitialAdDidDeepLink ---- placementID: ${value.placementID} ---- extra:${value.extraMap}");
break;
// Ad closed
case InterstitialStatus.interstitialAdDidClose:
print("flutter interstitialAdDidClose ---- placementID: ${value.placementID} ---- extra:${value.extraMap}");
break;
case InterstitialStatus.interstitialUnknown:
print("flutter interstitialUnknown");
break;
}
});
}