show static method
Future<void>
show({})
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);
}