static void showInterstitialAd(String adId,
{AdCallback? onAdLoad,
AdCallback? onAdShow,
AdCallback? onAdClick,
AdCallback? onAdClose,
AdCallback? onAdDetailClose,
AdCallback? onError}) {
_methodChannel.invokeMethod(
"showInterstitialAd", {"_channelId": _channelId, "adId": adId});
EventChannel eventChannel =
EventChannel("com.zjsdk.adsdk/event_$_channelId");
eventChannel.receiveBroadcastStream().listen((event) {
switch (event["event"]) {
case "interstitialAdDidLoad":
onAdLoad?.call("interstitialAdDidLoad", "");
break;
case "interstitialAdDidPresentScreen":
onAdShow?.call("interstitialAdDidPresentScreen", "");
break;
case "interstitialAdDidClick":
onAdClick?.call("interstitialAdDidClick", "");
break;
case "interstitialAdDidClose":
onAdClose?.call("interstitialAdDidClose", "");
break;
case "interstitialAdDetailDidClose":
onAdDetailClose?.call("interstitialAdDetailDidClose", "");
break;
case "interstitialAdError":
onError?.call("interstitialAdError", event["error"]);
break;
}
});
}
//插屏广告数据加载成功回调
interstitialAdDidLoad
//插屏广告错误回调
interstitialAdError
//插屏广告展示
interstitialAdDidPresentScreen
//插屏广告点击
interstitialAdDidClick
//插屏广告关闭
interstitialAdDidClose
//插屏广告详情页关闭
interstitialAdDetailDidClose
ZjsdkFlutter.showInterstitialAd(
"J9666281550",
onAdLoad: (String id,String msg) {
print("InterstitialAd onAdLoad");
},
onAdShow: (String id,String msg) {
print("InterstitialAd onAdShow");
},
onAdClick: (String id,String msg) {
print("InterstitialAd onAdClick");
},
onAdClose: (String id,String msg) {
print("InterstitialAd onAdClose");
},
onAdDetailClose: (String id,String msg){
print("InterstitialAd onAdDetailClose");
},
onError: (String id, String msg) {
print("InterstitialAd onError = "+(msg));
},
);