loadInterstitialAd static method
void
loadInterstitialAd(
- String codeId, {
- required AdLoadAdCallback onAdLoad,
- required AdCallback onAdShow,
- required AdCallback onAdClick,
- required AdCallback onAdClose,
- required AdErrorCallback onAdError,
Implementation
static void loadInterstitialAd(String codeId,
{required AdLoadAdCallback onAdLoad,
required AdCallback onAdShow,
required AdCallback onAdClick,
required AdCallback onAdClose,
required AdErrorCallback onAdError}) {
MethodChannel _methodChannel = new MethodChannel("com.fusion.ad/method");
String eventId = "loadInterstitialAd";
_methodChannel.invokeMethod(
"loadInterstitialAd", {"eventId": eventId, "codeId": codeId});
EventChannel eventChannel =
EventChannel("com.fusion.ad/msg_event_$eventId");
eventChannel.receiveBroadcastStream().listen((event) {
switch (event["event"]) {
case "onAdLoad":
onAdLoad.call(event["ecpm"]);
break;
case "onAdShow":
onAdShow.call();
break;
case "onAdClick":
onAdClick.call();
break;
case "onAdClose":
onAdClose.call();
break;
case "onAdError":
onAdError.call(event["code"], event["msg"]);
break;
}
});
}