AdBreakPlacement.rewarded constructor

AdBreakPlacement.rewarded({
  1. String? name,
  2. H5BeforeAdCallback? beforeAd,
  3. H5AfterAdCallback? afterAd,
  4. required H5BeforeRewardCallback? beforeReward,
  5. required H5AdDismissedCallback? adDismissed,
  6. required H5AdViewedCallback? adViewed,
  7. H5AdBreakDoneCallback? adBreakDone,
})

Convenience factory to create a rewarded ad placement configuration.

The following parameters are available:

  • name: A name for this particular ad placement within your game. It is an internal identifier, and is not shown to the player. Recommended.
  • beforeAd: Called before the ad is displayed. The game should pause and mute the sound. These actions must be done synchronously. The ad will be displayed immediately after this callback finishes..
  • afterAd: Called after the ad is finished (for any reason). For rewarded ads, it is called after either adDismissed or adViewed, depending on player actions
  • beforeReward: Called if a rewarded ad is available. The function should take a single argument showAdFn which must be called to display the rewarded ad.
  • adDismissed: Called if the player dismisses the ad before it completes. In this case the reward should not be granted.
  • adViewed: Called when the player completes the ad and should be granted the reward.
  • adBreakDone: Always called as the last step in an adBreak, even if there was no ad shown. Takes as argument a placementInfo object. See AdBreakDonePlacementInfo, and: https://developers.google.com/ad-placement/apis/adbreak#adbreakdone_and_placementinfo

See: https://developers.google.com/ad-placement/apis#rewarded_ads

Implementation

factory AdBreakPlacement.rewarded({
  String? name,
  H5BeforeAdCallback? beforeAd,
  H5AfterAdCallback? afterAd,
  required H5BeforeRewardCallback? beforeReward,
  required H5AdDismissedCallback? adDismissed,
  required H5AdViewedCallback? adViewed,
  H5AdBreakDoneCallback? adBreakDone,
}) {
  return AdBreakPlacement(
    type: BreakType.reward,
    name: name,
    beforeAd: beforeAd,
    afterAd: afterAd,
    beforeReward: beforeReward,
    adDismissed: adDismissed,
    adViewed: adViewed,
    adBreakDone: adBreakDone,
  );
}