> ## Documentation Index
> Fetch the complete documentation index at: https://guide.daro.so/llms.txt
> Use this file to discover all available pages before exploring further.

# 리워드 비디오 광고

> DARO Flutter SDK를 통해 리워드 비디오 광고를 구현하는 방법을 알아봅니다.

## 리워드 비디오 형태 소개

* 광고 시청을 대가로 인앱 가치를 지닌 보상(재화, 기능, 컨텐츠 등)을 제공하는 형태의 광고입니다.
* 보상을 대가로 시청하므로 동영상 광고의 스킵이 불가능하며 일반적인 길이는 30초입니다.

![Rv Example Image Pn](https://mintcdn.com/delightroom-5a71a6a8/dxU0bpsPoPvkYh_g/sdk-integration/common-img/ad-formats/rv-example-image.png?fit=max\&auto=format\&n=dxU0bpsPoPvkYh_g\&q=85\&s=42c4b8429cf25ce598c679e6eee00f70)

### How It Works

![Rv Example Gif Gi](https://mintcdn.com/delightroom-5a71a6a8/dxU0bpsPoPvkYh_g/sdk-integration/common-img/ad-formats/rv-example-gif.gif?s=e6a8679d28bbe4600a449121ba4bbe53)

***

## 인스턴스 생성 및 콜백 설정

`DaroRewardedAd` 인스턴스를 생성하고 콜백을 설정합니다.

```dart theme={null}
import 'package:daro_flutter/daro_flutter.dart';
```

```dart theme={null}
final rewardedAd = DaroRewardedAd(adUnitId: '{YOUR_AD_UNIT_ID}');

rewardedAd.onAdLoadSuccess = (adInfo) {
  print('Rewarded ad loaded');
};
rewardedAd.onAdLoadFail = (error) {
  print('Rewarded ad failed to load: ${error.message}');
};
rewardedAd.onAdImpression = (adInfo) {
  print('Rewarded ad impression');
};
rewardedAd.onAdClicked = (adInfo) {
  print('Rewarded ad clicked');
};
rewardedAd.onAdShown = (adInfo) {
  print('Rewarded ad shown');
};
rewardedAd.onAdFailedToShow = (error) {
  print('Rewarded ad failed to show: ${error.message}');
};
rewardedAd.onAdDismiss = (adInfo) {
  print('Rewarded ad dismissed');
};
rewardedAd.onEarnedReward = (adInfo, rewardItem) {
  print('Earned reward: ${rewardItem.amount} ${rewardItem.type}');
};
```

### 리워드 콜백

`onEarnedReward` 콜백은 사용자가 광고를 끝까지 시청하여 보상을 획득했을 때 호출됩니다. `DaroRewardItem`을 통해 보상 정보를 확인할 수 있습니다.

| 속성 | 설명 |
| - | - |
| `amount` | 보상 수량 |
| `type` | 보상 유형 |

## 광고 로드하기

`load()`를 호출하여 광고를 로드합니다.

```dart theme={null}
rewardedAd.load();
```

## 커스텀 데이터 설정

`setCustomData()`를 사용하여 S2S(Server-to-Server) 리워드 콜백에 포함할 커스텀 데이터를 설정할 수 있습니다. `show()` 호출 전에 설정해야 합니다.

```dart theme={null}
await rewardedAd.setCustomData('your_custom_data');
```

## 광고 보여주기

`isReady()`로 광고 준비 여부를 확인한 후 `show()`로 광고를 표시합니다.

```dart theme={null}
final isReady = await rewardedAd.isReady();

if (isReady) {
  await rewardedAd.setCustomData('your_custom_data');
  rewardedAd.show();
}
```

## 리소스 해제

광고 사용이 끝나면 `dispose()`를 호출하여 리소스를 해제합니다.

```dart theme={null}
rewardedAd.dispose();
```

### 구현 예시

> [accordion] `DaroRewardedAd` 구현 예시입니다.
>
> ```dart theme={null}
> import 'package:flutter/material.dart';
> import 'package:daro_flutter/daro_flutter.dart';
>
> class RewardedAdPage extends StatefulWidget {
>   const RewardedAdPage({super.key});
>
>   @override
>   State<RewardedAdPage> createState() => _RewardedAdPageState();
> }
>
> class _RewardedAdPageState extends State<RewardedAdPage> {
>   late final DaroRewardedAd _rewardedAd;
>   String _status = 'Not Loaded';
>
>   @override
>   void initState() {
>     super.initState();
>     _rewardedAd = DaroRewardedAd(adUnitId: '{YOUR_AD_UNIT_ID}');
>     _setupCallbacks();
>   }
>
>   void _setupCallbacks() {
>     _rewardedAd.onAdLoadSuccess = (adInfo) {
>       setState(() => _status = 'Loaded');
>     };
>
>     _rewardedAd.onAdLoadFail = (error) {
>       setState(() => _status = 'Failed to Load');
>       print('Rewarded ad failed to load: ${error.message}');
>     };
>
>     _rewardedAd.onAdShown = (adInfo) {
>       setState(() => _status = 'Shown');
>     };
>
>     _rewardedAd.onAdFailedToShow = (error) {
>       setState(() => _status = 'Failed to Show');
>     };
>
>     _rewardedAd.onAdDismiss = (adInfo) {
>       setState(() => _status = 'Not Loaded');
>     };
>
>     _rewardedAd.onAdClicked = (adInfo) {
>       print('Rewarded ad clicked');
>     };
>
>     _rewardedAd.onAdImpression = (adInfo) {
>       print('Rewarded ad impression');
>     };
>
>     _rewardedAd.onEarnedReward = (adInfo, rewardItem) {
>       ScaffoldMessenger.of(context).showSnackBar(
>         SnackBar(content: Text('Reward: ${rewardItem.amount} ${rewardItem.type}')),
>       );
>     };
>   }
>
>   @override
>   void dispose() {
>     _rewardedAd.dispose();
>     super.dispose();
>   }
>
>   @override
>   Widget build(BuildContext context) {
>     return Scaffold(
>       appBar: AppBar(title: const Text('Rewarded Ad')),
>       body: Center(
>         child: Column(
>           mainAxisAlignment: MainAxisAlignment.center,
>           children: [
>             Text('Status: $_status'),
>             const SizedBox(height: 16),
>             ElevatedButton(
>               onPressed: () async {
>                 final isReady = await _rewardedAd.isReady();
>                 if (isReady) {
>                   await _rewardedAd.setCustomData('user_id_1234');
>                   _rewardedAd.show();
>                 } else {
>                   setState(() => _status = 'Loading...');
>                   _rewardedAd.load();
>                 }
>               },
>               child: Text(_status == 'Loaded' ? 'Show Rewarded' : 'Load Rewarded'),
>             ),
>           ],
>         ),
>       ),
>     );
>   }
> }
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.