show static method

Future<void> show({
  1. required String placementId,
  2. dynamic onRewardedShowed(
    1. String placementId
    )?,
  3. dynamic onRewardedClicked(
    1. String placementId
    )?,
  4. dynamic onRewardedClosed(
    1. String placementId
    )?,
  5. dynamic onRewardedFailedShow(
    1. String placementId,
    2. UnityMediationAdsShowError error,
    3. String errorMessage
    )?,
  6. dynamic onUserRewarded(
    1. String placementId
    )?,
})

Show an ad using the provided placement ID.

  • placementId - the placement ID, as defined in Unity Ads admin tools.
  • onRewardedShowed - Called when Unity Mediation has shown ad with a specific placement.
  • onRewardedClicked - Called when UnityAds has received a click while showing ad with a specific placement.
  • onRewardedClosed - Called when Unity Mediation has closed ad with a specific placement.
  • onRewardedFailedShow - Called when UnityAds has failed to show a specific placement with an error message and error category.
  • onUserRewarded - A reward may be issued based on the reward callback. Timing of this event may vary depending on the ad network to serve the impression.

Implementation

static Future<void> show({
  required String placementId,
  Function(String placementId)? onRewardedShowed,
  Function(String placementId)? onRewardedClicked,
  Function(String placementId)? onRewardedClosed,
  Function(String placementId, UnityMediationAdsShowError error, String errorMessage)? onRewardedFailedShow,
  Function(String placementId)? onUserRewarded,
}) async {
  UnityAdsBase.channels
      .putIfAbsent(
      placementId, () => MethodChannel('${rewardedAdChannel}_$placementId'))
      .setMethodCallHandler((call) => _showMethodCall(
      call, onRewardedShowed, onRewardedClicked, onRewardedClosed, onRewardedFailedShow, onUserRewarded));

  final args = <String, dynamic>{
    placementIdParameter: placementId
  };
  await UnityAdsBase.channel.invokeMethod(rewardedAdShowMethod, args);
}