---
metadata:
  - name: generator
    content: Diplodoc Platform v5.57.3
alternate:
  - https://ads.yandex.com/helpcenter/en/easy/integration/flutter/formats/rewarded.md
  - https://ads.yandex.com/helpcenter/ru/easy/integration/flutter/formats/rewarded.md
  - https://ads.yandex.com/helpcenter/zh/easy/integration/flutter/formats/rewarded.md
  - href: ru/easy/integration/flutter/formats/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://ads.yandex.com/helpcenter/ru/llms.txt

# Реклама с вознаграждением

<!-- source: ru/easy/_includes/sdk-guide.md -->
Реклама с вознаграждением (Rewarded) — это полноэкранный рекламный формат, за просмотр которого пользователь получает бонус или награду (например: внутриигровые монеты, доступ к премиум-функциям, повтор попытки и т. д.).

{% note info %}

Пользователь принимает решение **самостоятельно** — не смотреть рекламу или дождаться получения награды.

{% endnote %}
<!-- endsource: ru/easy/_includes/sdk-guide.md -->

<!-- source: ru/easy/_includes/notes-flutter-easy-guide.md -->
{% note info %}

Пример работы всех типов форматов есть в [демопроекте](https://ads.yandex.com/helpcenter/ru/easy/integration/flutter/testing.md#demo).

{% endnote %}
<!-- endsource: ru/easy/_includes/notes-flutter-easy-guide.md -->

#|
||

**Сущность**

|

**Описание**

||
||

`adUnitId`

|

Используйте:

- **development mode** — для работы с [демоблоками](https://ads.yandex.com/helpcenter/ru/easy/integration/flutter/testing.md#blocks);

- **production mode** — для работы с `R-M-XXXXXX-Y` (уточните реальный ID в интерфейсе Рекламной сети Яндекса). `R-M-XXXXXX-Y` — это вид рабочего рекламного ID, по которому будут приходить разные креативы.

||
|#

## Пример создания рекламы с вознаграждением

```dart
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:yandex_mobileads/mobile_ads.dart';

class RewardedPage extends StatefulWidget {
  const RewardedPage({super.key});

  @override
  State<RewardedPage> createState() => _RewardedPageState();
}

class _RewardedPageState extends State<RewardedPage> {
  static const _tag = 'Rewarded';
  static const _adUnitId = 'demo-rewarded-yandex';

  final RewardedAdLoader _loader = RewardedAdLoader();
  RewardedAd? _ad;
  String _status = 'Initializing...';
  String _reward = '';

  @override
  void initState() {
    super.initState();
    _init();
  }

  @override
  void dispose() {
    _ad?.destroy();
    super.dispose();
  }

  Future<void> _init() async {
    setState(() => _status = 'Loading ad...');
    try {
      final ad = await _loader.loadAd(
        adRequest: AdRequest(adUnitId: _adUnitId),
      );
      if (!mounted) {
        ad.destroy();
        return;
      }
      _ad = ad;
      setState(() => _status = 'Showing...');
      await _show();
    } on AdRequestError catch (error) {
      debugPrint('[$_tag] onAdFailedToLoad: ${error.description}');
      if (mounted) setState(() => _status = 'Error: ${error.description}');
    }
  }

  Future<void> _show() async {
    final ad = _ad;
    if (ad == null) return;

    ad.setAdEventListener(
      eventListener: RewardedAdEventListener(
        onAdShown: () => debugPrint('[$_tag] onAdShown'),
        onAdDismissed: () {
          debugPrint('[$_tag] onAdDismissed');
          if (mounted) setState(() => _status = _reward.isEmpty ? 'Closed' : 'Reward received!');
        },
        onAdClicked: () => debugPrint('[$_tag] onAdClicked'),
        onAdFailedToShow: (error) {
          debugPrint('[$_tag] onAdFailedToShow: ${error.description}');
          if (mounted) setState(() => _status = 'Show error: ${error.description}');
        },
        onAdImpression: (ImpressionData impressionData) =>
            debugPrint('[$_tag] onAdImpression: $impressionData'),
        onRewarded: (reward) {
          debugPrint('[$_tag] onRewarded: ${reward.amount} ${reward.type}');
          if (mounted) setState(() => _reward = '+${reward.amount} ${reward.type}');
        },
      ),
    );

    await ad.show();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Rewarded')),
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            if (_reward.isEmpty && !_status.contains('Error') && !_status.contains('Closed'))
              const CircularProgressIndicator(),
            const SizedBox(height: 16),
            Text(_status),
            if (_reward.isNotEmpty) ...[
              const SizedBox(height: 16),
              Text(_reward, style: const TextStyle(color: Colors.green, fontSize: 24, fontWeight: FontWeight.bold)),
            ],
          ],
        ),
      ),
    );
  }
}

```

## Проверка интеграции

<!-- source: ru/easy/_includes/notes-flutter-easy-guide.md -->
Соберите и запустите проект. Успешную интеграцию можно проверить в **Logcat** **Android Studio** по ключевому слову `YandexAds`:
<!-- endsource: ru/easy/_includes/notes-flutter-easy-guide.md -->

```
[Integration] Ad type rewarded was integrated successfully
```
