showRewardedAd method

Future<bool> showRewardedAd({
  1. required String adUnitId,
})

Shows a preloaded rewarded ad for the given ad unit ID.

Returns true if the ad is shown successfully, false if no ad is loaded or if showing fails.

When the user completes watching the ad, the onUserEarnedReward callback will be triggered.

Make sure to preload an ad first using preloadRewardedAd.

Implementation

Future<bool> showRewardedAd({required String adUnitId}) async {
  try {
    final result = await _channel.invokeMethod<bool>(
      'showRewardedAd',
      {'adUnitId': adUnitId},
    );
    return result ?? false;
  } catch (e) {
    debugPrint('Error showing rewarded ad: $e');
    return false;
  }
}