loadRewardVideoAd static method

void loadRewardVideoAd(
  1. String codeId, {
  2. required AdLoadAdCallback onAdLoad,
  3. required AdCallback onAdShow,
  4. required AdCallback onAdClick,
  5. required AdCallback onVideoComplete,
  6. required AdCallback onReward,
  7. required AdCallback onAdClose,
  8. 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;
    }
  });
}