loadAndShowRewardAd method

  1. @override
void loadAndShowRewardAd({
  1. AdModuleWithCallBacks? adModuleCallBacks,
})
override

Implementation

@override
void loadAndShowRewardAd({AdModuleWithCallBacks? adModuleCallBacks}) {
  final rewardedAd = RewardedAd(
    GlobalAdVariables.adNetworkIds?['facebook']?.rewardId ?? "",
  );
  rewardedAd.listener = RewardedAdListener(
    onLoaded: () {
      rewardedAd.show();
      if (adModuleCallBacks != null) {
        if (adModuleCallBacks.onAdLoaded != null) {
          adModuleCallBacks.onAdLoaded!();
        }
      }
    },
    onVideoComplete: () {
      rewardedAd.destroy();
      log('Facebook:[Reward]->Video completed');
      if (adModuleCallBacks != null) {
        if (adModuleCallBacks.onCloseEvent != null) {
          adModuleCallBacks.onCloseEvent!();
        }
      }
    },
    onError: (code, message) {
      if (adModuleCallBacks != null) {
        if (adModuleCallBacks.onFailed != null) {
          adModuleCallBacks.onFailed!();
        }
      }
    },
  );
  rewardedAd.load();
}