> ## 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를 통해 앱 오프닝 광고를 구현하는 방법을 알아봅니다.

## 앱 오프닝 광고 포맷 소개

* 앱이 시작되거나 포그라운드로 전환될 때 표시되는 화면 전체를 사용하는 광고입니다.
* 앱 로딩 화면이나 스플래시 화면에서 자연스럽게 노출됩니다.

***

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

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

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

```dart theme={null}
final appOpenAd = DaroAppOpenAd(adUnitKey: 'YOUR_AD_UNIT_KEY');

appOpenAd.onAdLoadSuccess = (adInfo) {
  print('App open ad loaded');
};
appOpenAd.onAdLoadFail = (error) {
  print('App open ad failed to load: ${error.message}');
};
appOpenAd.onAdImpression = (adInfo) {
  print('App open ad impression');
};
appOpenAd.onAdClicked = (adInfo) {
  print('App open ad clicked');
};
appOpenAd.onAdShown = (adInfo) {
  print('App open ad shown');
};
appOpenAd.onAdFailedToShow = (error) {
  print('App open ad failed to show: ${error.message}');
};
appOpenAd.onAdDismiss = (adInfo) {
  print('App open ad dismissed');
};
```

## 광고 로드하기

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

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

## 광고 보여주기

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

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

if (isReady) {
  appOpenAd.show();
}
```

## 리소스 해제

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

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

### 구현 예시

> [accordion] `DaroAppOpenAd` 구현 예시입니다.
>
> ```dart theme={null}
> import 'package:flutter/material.dart';
> import 'package:daro_flutter/daro_flutter.dart';
>
> class AppOpenAdPage extends StatefulWidget {
>   const AppOpenAdPage({super.key});
>
>   @override
>   State<AppOpenAdPage> createState() => _AppOpenAdPageState();
> }
>
> class _AppOpenAdPageState extends State<AppOpenAdPage> with WidgetsBindingObserver {
>   late final DaroAppOpenAd _appOpenAd;
>   String _status = 'Not Loaded';
>
>   @override
>   void initState() {
>     super.initState();
>     WidgetsBinding.instance.addObserver(this);
>     _appOpenAd = DaroAppOpenAd(adUnitKey: 'YOUR_AD_UNIT_KEY');
>     _setupCallbacks();
>   }
>
>   void _setupCallbacks() {
>     _appOpenAd.onAdLoadSuccess = (adInfo) {
>       setState(() => _status = 'Loaded');
>     };
>
>     _appOpenAd.onAdLoadFail = (error) {
>       setState(() => _status = 'Failed to Load');
>     };
>
>     _appOpenAd.onAdShown = (adInfo) {
>       setState(() => _status = 'Shown');
>     };
>
>     _appOpenAd.onAdFailedToShow = (error) {
>       setState(() => _status = 'Failed to Show');
>     };
>
>     _appOpenAd.onAdDismiss = (adInfo) {
>       setState(() => _status = 'Not Loaded');
>       // 광고가 닫힌 후 다시 로드
>       _appOpenAd.load();
>     };
>
>     _appOpenAd.onAdClicked = (adInfo) {
>       print('App open ad clicked');
>     };
>
>     _appOpenAd.onAdImpression = (adInfo) {
>       print('App open ad impression');
>     };
>   }
>
>   @override
>   void didChangeAppLifecycleState(AppLifecycleState state) {
>     if (state == AppLifecycleState.resumed) {
>       _showAppOpenAd();
>     }
>   }
>
>   Future<void> _showAppOpenAd() async {
>     final isReady = await _appOpenAd.isReady();
>     if (isReady) {
>       _appOpenAd.show();
>     }
>   }
>
>   @override
>   void dispose() {
>     WidgetsBinding.instance.removeObserver(this);
>     _appOpenAd.dispose();
>     super.dispose();
>   }
>
>   @override
>   Widget build(BuildContext context) {
>     return Scaffold(
>       appBar: AppBar(title: const Text('App Open Ad')),
>       body: Center(
>         child: Column(
>           mainAxisAlignment: MainAxisAlignment.center,
>           children: [
>             Text('Status: $_status'),
>             const SizedBox(height: 16),
>             ElevatedButton(
>               onPressed: () {
>                 setState(() => _status = 'Loading...');
>                 _appOpenAd.load();
>               },
>               child: const Text('Load App Open Ad'),
>             ),
>             const SizedBox(height: 8),
>             ElevatedButton(
>               onPressed: () async {
>                 final isReady = await _appOpenAd.isReady();
>                 if (isReady) {
>                   _appOpenAd.show();
>                 }
>               },
>               child: const Text('Show App Open Ad'),
>             ),
>           ],
>         ),
>       ),
>     );
>   }
> }
> ```


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