showRewardedAd static method

Future<void> showRewardedAd({
  1. required String adUnitId,
  2. dynamic onStart(
    1. String adUnitId
    )?,
  3. dynamic onClick(
    1. String adUnitId
    )?,
  4. dynamic onRewarded(
    1. String adUnitId,
    2. UnityMediationReward reward
    )?,
  5. dynamic onClosed(
    1. String adUnitId
    )?,
  6. dynamic onFailed(
    1. String adUnitId,
    2. ShowError error,
    3. String errorMessage
    )?,
  7. String? userId,
  8. String? customizedData,
})

Show a rewarded Ad.

  • adUnitId - The ID of the rewarded ad unit.
  • onStart - called on when an ad has started playback.
  • onClick - called on when an ad has been clicked by the user.
  • onRewarded - called on when an ad should reward the user.
  • onClosed - called on when an ad has closed after playback has completed.
  • onFailed - called on when an ad has a failure during playback. Server-to-server redeem callbacks: https://docs.unity.com/mediation/S2SRedeemCallbacks.html
  • userId - The publisher's user id. This will be passed along in the S2S reward callback feature to the publisher's S2S server.
  • customizedData - The publisher's custom data in whatever string format they wish (ex. JSON). This can be any data that the publisher wants forwarded to their S2S server.

Implementation

static Future<void> showRewardedAd({
  required String adUnitId,
  Function(String adUnitId)? onStart,
  Function(String adUnitId)? onClick,
  Function(String adUnitId, UnityMediationReward reward)? onRewarded,
  Function(String adUnitId)? onClosed,
  Function(String adUnitId, ShowError error, String errorMessage)? onFailed,
  String? userId,
  String? customizedData,
}) async {
  await _showAd(
    methodName: showRewardedAdMethod,
    adUnitId: adUnitId,
    onStart: onStart,
    onClick: onClick,
    onClosed: onClosed,
    onFailed: onFailed,
    onRewarded: onRewarded,
    userId: userId,
    customizedData: customizedData,
  );
}