---
metadata:
  - name: generator
    content: Diplodoc Platform v5.57.3
alternate:
  - https://boost.yandex.com/doc/en/ad-monetization/dev/flutter/rewarded.md
  - https://boost.yandex.com/doc/ru/ad-monetization/dev/flutter/rewarded.md
  - href: en/ad-monetization/dev/flutter/rewarded.md
    type: text/markdown
    title: Markdown version
  - href: llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://boost.yandex.com/doc/en/llms.txt

# Rewarded ads

<!-- source: en/ad-monetization/dev/_includes/rewarded.md -->
Rewarded ads are a popular fullscreen ad format where users receive incentives for viewing ads.
<!-- endsource: en/ad-monetization/dev/_includes/rewarded.md -->

<!-- source: en/ad-monetization/dev/_includes/rewarded.md -->
Ad impressions are opt-in: for example, users can initiate them to get game bonuses or extra lives.
<!-- endsource: en/ad-monetization/dev/_includes/rewarded.md -->

<!-- source: en/ad-monetization/dev/_includes/rewarded.md -->
Strong user motivation makes this ad format the most popular and profitable adoption in free apps.
<!-- endsource: en/ad-monetization/dev/_includes/rewarded.md -->

{% cut "Appearance" %}

{% list tabs %}

- Combinatorial ads

  <iframe width="200" height="405.5" allow="autoplay" src="https://runtime.strm.yandex.ru/player/video/vplv6tshzb3euhokoa5q?autoplay=1&mute=0&loop=1&loop=1" frameborder="0" allowfullscreen></iframe>

- Video ad

  <iframe width="200" height="405.5" allow="autoplay" src="https://runtime.strm.yandex.ru/player/video/vplvv2aom7x2nte5gckn?autoplay=1&mute=0&loop=1&loop=1" frameborder="0" allowfullscreen></iframe>

{% endlist %}

{% endcut %}

This guide will show you how to integrate interstitial ads into a Flutter app.
Besides code samples and instructions, it also contains format-specific recommendations and links to additional resources.


## Prerequisite {#pre}

<!-- source: en/ad-monetization/dev/_includes/pre-flutter.md -->
1. Follow the Yandex Mobile Ads Flutter plugin integration steps described under [Quick start](https://boost.yandex.com/doc/en/ad-monetization/dev/flutter/quick-start.md).
2. Make sure that you have the [latest version of the Yandex Mobile Ads Flutter plugin](https://boost.yandex.com/doc/en/ad-monetization/dev/platforms.md). If you're using mediation, update to the most recent [single build version](https://boost.yandex.com/doc/en/ad-monetization/dev/platforms.md).
<!-- endsource: en/ad-monetization/dev/_includes/pre-flutter.md -->

## Implementation {#implement}

Key steps for integrating rewarded ads:

* Create and configure a `RewardedAdLoader`.
* Load the `RewardedAd` object.
* Register the `RewardedAdEventListener` listener for ad callback methods.
* Display the `RewardedAd` object.
* Reward the user for viewing the ad.

## Features of rewarded ad integration {#features}

If the `onAdFailedToLoad()` callback returns an error, don't try to load a new ad again. If there's no other option, limit the number of ad load retries. This will help avoid constant unsuccessful requests and connection issues if there are limitations.

## Loading ads

To load your rewarded ads, create a `RewardedAdLoader` object.

You will need the ad unit ID (adUnitId) obtained from the Boost interface.

You can expand ad request parameters through `AdRequest`, by passing user interests, contextual page data, location, or other additional info. Adding extra context to ad requests can greatly improve ad relevance. To learn more, see [Ad targeting](https://boost.yandex.com/doc/en/ad-monetization/dev/flutter/target.md).

The example below shows how to load a rewarded ad:

```dart
final _adLoader = RewardedAdLoader();
RewardedAd? _ad;

@override
void initState() {
  super.initState();
  YandexAds.initialize();
  _loadRewardedAd();
}

Future<void> _loadRewardedAd() async {
  try {
    _ad = await _adLoader.loadAd(
      adRequest: AdRequest(adUnitId: 'R-M-XXXXXX-Y'), // For debugging, you can use 'demo-rewarded-yandex'
    );
  } on AdRequestError catch (error) {
    // Ad failed to load with AdRequestError.
    // Attempting to load a new ad from the error handler is strongly discouraged.
  }
}
```

## Displaying ads

Rewarded ads are an incentivized ad format that allows users to earn rewards by viewing ads. These rewards may include extra lives or the ability to advance to the next level in a game. The reward format is determined by the app itself.

To track the rewarded ad lifecycle and issue rewards, set the `RewardedAdEventListener` callback method listener for the `RewardedAd` object.

To show a rewarded ad, use the `show()` method. To wait until viewing is complete, use the `waitForDismiss()` method:

```dart
_showAd() async {
  _ad?.setAdEventListener(
      eventListener: RewardedAdEventListener(
    onAdShown: () {
      // Called when ad is shown.
    },
    onAdFailedToShow: (error) {
      // Called when an ad failed to show.
      // Destroy the ad so you don't show the ad a second time.
      _ad?.destroy();
      _ad = null;

      // Now you can preload the next ad.
      _loadRewardedAd();
    },
    onAdClicked: () {
      // Called when a click is recorded for an ad.
    },
    onAdDismissed: () {
      // Called when ad is dismissed.
      // Destroy the ad so you don't show the ad a second time.
      _ad?.destroy();
      _ad = null;

      // Now you can preload the next ad.
      _loadRewardedAd();
    },
    onAdImpression: (impressionData) {
      // Called when an impression is recorded for an ad.
    },
    onRewarded: (Reward reward) {
      // Called when the user can be rewarded.
    }
  ));

  await _ad?.show();
  final reward = await _ad?.waitForDismiss();
  if (reward != null) {
    print('got ${reward.amount} of ${reward.type}');
  }
}
```

## Releasing resources

Call the `destroy()` method for previously shown ads. That releases the resources and prevents memory leaks.

Don't store links to previously rendered ads.

You can use the `onAdDismissed` callback method for the following actions:

```dart
_ad?.setAdEventListener(
    eventListener: RewardedAdEventListener(
        //...
        onAdDismissed: () {
          _ad?.destroy();
          _ad = null;
        },
        //...
    ));
```

## Testing rewarded ad integration {#test}

{% list tabs %}

- Android

  <!-- source: en/ad-monetization/dev/_includes/test-android-rewarded.md -->
  ### Using demo ad units for ad testing {#demo-blocks}

  Use test ads to check your rewarded ad integration and the app itself. To make sure that test ads are returned for each ad request, you can use a special demo ad placement ID.

  Demo adUnitId: `demo-rewarded-yandex`.

  {% note warning %}

  Before publishing your app in the store, make sure to replace the demo placement ID with the real ID you obtained in the Boost interface.

  {% endnote %}

  For the list of all available demo ad placement IDs, see [Demo ad units for testing](https://boost.yandex.com/doc/en/ad-monetization/dev/android/demo-blocks.md).

  ### Testing ad integration {#test-int}

  You can check if your rewarded ads are integrated correctly using the SDK's built-in analyzer. A detailed report with the test results will appear in the log.

  To view the report, search for the keyword “YandexAds” in [Logcat](https://developer.android.com/studio/command-line/logcat), a tool for debugging Android apps.
  ```bash
  adb logcat -v brief '*:S YandexAds'
  ```

  If the integration is successful, the following message is returned:
  ```bash
  adb logcat -v brief '*:S YandexAds'
  mobileads$ adb logcat -v brief '*:S YandexAds'
  I/YandexAds(13719): [Integration] Ad type rewarded was integrated successfully
  ```

  If there are any rewarded ad integration issues, you'll get a detailed issue report and troubleshooting recommendations.
  <!-- endsource: en/ad-monetization/dev/_includes/test-android-rewarded.md -->

- iOS

  ### Using demo ad units for ad testing

  <!-- source: en/ad-monetization/dev/_includes/test-ios-rewarded.md -->
  Use test ads to check your ad integration and the app itself. To make sure that test ads are returned for each ad request, you can use a special demo ad placement ID.

  Demo adUnitId: `demo-rewarded-yandex`.

  {% note warning %}

  Before publishing your app in the store, make sure to replace the demo placement ID with the real ID you obtained in the Boost interface.

  {% endnote %}

  For the list of all available demo ad placement IDs, see [Demo ad units for testing](https://boost.yandex.com/doc/en/ad-monetization/dev/ios/demo-blocks.md).
  <!-- endsource: en/ad-monetization/dev/_includes/test-ios-rewarded.md -->

  ### Testing ad integration

  <!-- source: en/ad-monetization/dev/_includes/test-integration-ios.md -->
  You can test your ad integration using the native Console tool.

  To view detailed logs, call the `YandexAds` class's `enableLogging` method.

  ```swift
  YandexAds.enableLogging()
  ```

  To view SDK logs, go to the Console tool and set `Subsystem = com.mobile.ads.ads.sdk`. You can filter logs by category or error level.

  If you're having problems integrating ads, you'll get a detailed report on the issues and recommendations for how to fix them.

  <img src= "https://yastatic.net/s3/doc-binary/src/dev/mobile-ads/common/integration-ios-2.png">
  <!-- endsource: en/ad-monetization/dev/_includes/test-integration-ios.md -->

{% endlist %}

## Tips

### Ad preloading

<!-- source: en/ad-monetization/dev/_includes/preload.md -->
Loading an ad may take several seconds, depending on the number of ad networks connected in Mobile Mediation and the user's internet speed. We recommend preloading ads before displaying them.
<!-- endsource: en/ad-monetization/dev/_includes/preload.md -->

Call `load` in advance to display the loaded ad at the right moment.

To begin preloading the next ad immediately after serving the current one, you can link this process to the `onAdDismissed()` event.

<!-- source: en/ad-monetization/dev/_includes/cash-ads.md -->
If you cache ads on too many screens that are unlikely to be shown, your ad effectiveness could drop. For example, if users complete 2-3 game levels per session, you shouldn't cache ads for 6-7 screens. Your ad viewability could decrease otherwise, and the advertising system might deprioritize your app.

To ensure caching benefits your app, monitor the “Show rate” or “View rate” metrics in the Boost interface. If it's under 20%, you should probably revise your caching algorithm. The higher the percentage of impressions, the better.
<!-- endsource: en/ad-monetization/dev/_includes/cash-ads.md -->

## Additional resources {#resources}

* <!-- source: en/ad-monetization/dev/_includes/github-pubdev-links.md -->
  Link to [pub.dev](https://pub.dev/packages/yandex_mobileads/example).

  # Android {#android}

  Link to [GitHub](https://github.com/yandexmobile/yandex-ads-sdk-android).

  # Unity {#unity}

  Link to [GitHub](https://github.com/yandexmobile/yandex-ads-unity-plugin).

  # Flutter {#flutter}

  Link to [GitHub](https://github.com/yandexmobile/yandex-ads-flutter-plugin).

  # React Native {#react-native}
  Link to [GitHub](https://github.com/yandexmobile/yandex-ads-react-native-plugin).

  # Compose Multiplatform {#compose-multiplatform}
  Link to [GitHub](https://github.com/yandexmobile/yandex-ads-multiplatform).

  # iOS {#ios}

  Link to [GitHub](https://github.com/yandexmobile/yandex-ads-sdk-ios).

  # iOS inline {#ios-inline}

  Link to [GitHub](https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Examples/YandexMobileAdsExample/YandexMobileAdsExample/Yandex/Banner/InlineBannerViewController.swift).

  # iOS sticky {#ios-sticky}

  Link to [GitHub](https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Examples/YandexMobileAdsExample/YandexMobileAdsExample/Yandex/Banner/StickyBannerViewController.swift).

  # iOS interstitial {#ios-interstitial}

  Link to [GitHub](https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Examples/YandexMobileAdsExample/YandexMobileAdsExample/Yandex/Interstitial/InterstitialAdViewController.swift).

  # iOS app open ad {#ios-appopenad}

  Link to [GitHub](https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Examples/YandexMobileAdsExample/YandexMobileAdsExample/Yandex/AppOpenAd/AppOpenAdViewController.swift).

  # iOS rewarded {#ios-rewarded}

  Link to [GitHub](https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Examples/YandexMobileAdsExample/YandexMobileAdsExample/Yandex/Rewarded/RewardedAdViewController.swift).

  # iOS feed ad {#ios-feedad}

  Link to [GitHub](https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Examples/YandexMobileAdsExample/YandexMobileAdsExample/Adapters/Yandex/FeedAd/YandexFeedAdAdapter.swift).
  <!-- endsource: en/ad-monetization/dev/_includes/github-pubdev-links.md -->
