show static method

Future<void> show({
  1. required String placementId,
  2. dynamic onInterstitialShowed(
    1. String placementId
    )?,
  3. dynamic onInterstitialClicked(
    1. String placementId
    )?,
  4. dynamic onInterstitialClosed(
    1. String placementId
    )?,
  5. dynamic onInterstitialFailedShow(
    1. String placementId,
    2. UnityMediationAdsShowError error,
    3. String errorMessage
    )?,
})

Show an ad using the provided placement ID.

  • placementId - the placement ID, as defined in Unity Ads admin tools.
  • onInterstitialShowed - Called when Unity Mediation has shown ad with a specific placement.
  • onInterstitialClicked - Called when UnityAds has received a click while showing ad with a specific placement.
  • onInterstitialClosed - Called when Unity Mediation has closed ad with a specific placement.
  • onInterstitialFailedShow - Called when UnityAds has failed to show a specific placement with an error message and error category.

Implementation

static Future<void> show({
  required String placementId,
  Function(String placementId)? onInterstitialShowed,
  Function(String placementId)? onInterstitialClicked,
  Function(String placementId)? onInterstitialClosed,
  Function(String placementId, UnityMediationAdsShowError error, String errorMessage)? onInterstitialFailedShow,
}) async {
  UnityAdsBase.channels
      .putIfAbsent(
      placementId, () => MethodChannel('${interstitialAdChannel}_$placementId'))
      .setMethodCallHandler((call) => _showMethodCall(
      call, onInterstitialShowed, onInterstitialClicked, onInterstitialClosed, onInterstitialFailedShow));

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