> ## 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)

### 동작 방식

![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(adUnitKey: 'YOUR_AD_UNIT_KEY');

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();
}
```

광고가 닫히면 `isReady()`는 `false`를 반환합니다. 다음 광고를 표시하려면 같은 인스턴스에서 `load()`를 다시 호출하고 `onAdLoadSuccess` 콜백을 기다리세요.

## iOS 광고 표시 중 상태바 숨기기

Flutter SDK **2.0.5 이상**에서 사용할 수 있습니다.

상태바와 광고의 닫기 버튼이 겹치는 경우 `hideStatusBarDuringFullscreenAd`를 활성화할 수 있습니다. 기본값은 `false`이며 Android에서는 시스템 UI를 변경하지 않습니다.

```dart theme={null}
final ad = DaroRewardedAd(
  adUnitKey: 'YOUR_AD_UNIT_KEY',
  hideStatusBarDuringFullscreenAd: true,
);
```

SDK는 상태바 숨김 요청을 완료한 뒤 광고를 표시합니다. 광고 종료 또는 표시 실패 후에는 기본적으로 `SystemUiMode.edgeToEdge`로 복구합니다. `show()`의 반환은 광고 종료를 의미하지 않으므로, 호출 직후 앱에서 상태바를 복구하지 마세요.

이 옵션을 켠 iOS에서는 광고 표시 세션이 끝나기 전에 같은 인스턴스에서 `load()` 또는 `show()`를 호출하면 `StateError`가 발생합니다. 따라서 `onAdShown`에서 같은 인스턴스를 미리 로드하지 말고, `onAdDismiss` 또는 `onAdFailedToShow` 이후에 `load()`를 호출하세요.

앱이 평소 상태바를 숨기거나 수동 시스템 UI 설정을 사용한다면 복구할 설정을 명시하세요. Flutter는 현재 시스템 UI 설정을 조회하는 API를 제공하지 않으므로, SDK가 임의의 이전 설정을 자동으로 읽어 복구하지는 않습니다.

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

final ad = DaroRewardedAd(
  adUnitKey: 'YOUR_AD_UNIT_KEY',
  hideStatusBarDuringFullscreenAd: true,
  systemUiRestoreConfiguration: DaroSystemUiRestoreConfiguration(
    mode: SystemUiMode.manual,
    overlays: const [SystemUiOverlay.bottom], // 앱의 평소 상태: 상태바 숨김
  ),
);
```

광고 표시 중 `dispose()`를 호출해도 이미 표시된 광고를 강제로 닫지 않습니다. SDK는 실제 광고 종료 또는 표시 실패 콜백을 받은 뒤 시스템 UI를 복구합니다.

`SystemUiMode.manual`에는 `overlays` 목록을 반드시 전달해야 합니다. 빈 목록은 모든 시스템 UI 오버레이를 숨기는 설정입니다.

동시에 활성화된 광고 세션이 있으면 첫 세션의 복구 설정을 사용하고, 마지막 세션 종료 후 복구합니다. 광고 표시 중 앱이 별도로 `SystemChrome` 설정을 변경하면 SDK의 복구 설정이 마지막에 적용될 수 있습니다.

> [!WARNING]
>
> 상태바 숨김은 Flutter·iOS 버전, `UIViewControllerBasedStatusBarAppearance` 설정과 광고 화면의 제어권에 영향을 받습니다. iOS 27 SDK로 빌드한 앱에서 이 키가 `NO`이면 `SystemChrome` 설정이 무시되는 [Flutter 이슈](https://github.com/flutter/flutter/issues/192842)가 보고되어 있습니다. 키를 변경할 때는 앱 전체의 상태바 동작과 사용 중인 광고 디맨드에서 표시·종료를 함께 확인하세요.

## 리소스 해제

광고 사용이 끝나면 `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(adUnitKey: 'YOUR_AD_UNIT_KEY');
>     _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.