showVideoAd static method

Future<void> showVideoAd({
  1. required String placementId,
  2. String? serverId,
  3. dynamic onStart(
    1. String placementId
    )?,
  4. dynamic onSkipped(
    1. String placementId
    )?,
  5. dynamic onClick(
    1. String placementId
    )?,
  6. dynamic onComplete(
    1. String placementId
    )?,
  7. dynamic onFailed(
    1. String placementId,
    2. UnityAdsShowError error,
    3. String errorMessage
    )?,
})

Show an ad using the provided placement ID.

  • placementId - the placement ID, as defined in Unity Ads admin tools.
  • serverId
  • onStart - Called when UnityAds has started to show ad with a specific placement.
  • onSkipped - Called when UnityAds skippes show operation for a placement.
  • onClick - Called when UnityAds has received a click while showing ad with a specific placement.
  • onComplete - Called when UnityAds completes show operation successfully for a placement.
  • onFailed - Called when UnityAds has failed to show a specific placement with an error message and error category.

Implementation

static Future<void> showVideoAd({
  required String placementId,
  String? serverId,
  Function(String placementId)? onStart,
  Function(String placementId)? onSkipped,
  Function(String placementId)? onClick,
  Function(String placementId)? onComplete,
  Function(String placementId, UnityAdsShowError error, String errorMessage)?
  onFailed,
}) async {
  _adChannels
      .putIfAbsent(placementId, () => _AdMethodChannel(placementId))
      .update(
        onAdStart: onStart,
        onAdClick: onClick,
        onAdSkipped: onSkipped,
        onShowFailed: onFailed,
        onAdComplete: onComplete,
      );

  final args = <String, dynamic>{
    placementIdParameter: placementId,
    serverIdParameter: serverId,
  };
  await _channel.invokeMethod(showVideoMethod, args);
}