loadRewardVideoAd static method
void
loadRewardVideoAd(
- String codeId, {
- required AdLoadAdCallback onAdLoad,
- required AdCallback onAdShow,
- required AdCallback onAdClick,
- required AdCallback onVideoComplete,
- required AdCallback onReward,
- required AdCallback onAdClose,
- required AdErrorCallback onAdError,
Implementation
static void loadRewardVideoAd(String codeId,
{required AdLoadAdCallback onAdLoad,
required AdCallback onAdShow,
required AdCallback onAdClick,
required AdCallback onVideoComplete,
required AdCallback onReward,
required AdCallback onAdClose,
required AdErrorCallback onAdError}) {
MethodChannel _methodChannel = new MethodChannel("com.fusion.ad/method");
String eventId = "loadRewardVideo";
_methodChannel.invokeMethod(
"loadRewardVideo", {"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 "onVideoComplete":
onVideoComplete.call();
break;
case "onReward":
onReward.call();
break;
case "onAdClose":
onAdClose.call();
break;
case "onAdError":
onAdError.call(event["code"], event["msg"]);
break;
}
});
}