# Interstitial Ad

## 1. 기본 요건

* [<mark style="color:blue;">ADX Flutter SDK</mark>](/adx/flutter/integrate.md)를 프로젝트에 추가합니다.
* Interstitial Ad용으로 발급받은 ADX Ad Unit ID를 사용합니다.
* 광고를 요청하기 전에 [<mark style="color:blue;">SDK 초기화</mark>](/adx/flutter/sdk-integration/initialize.md)를 먼저 진행합니다.
  * **SDK 초기화는 앱 실행 시 한 번만 호출**하여 주시고, **광고 요청은 초기화가 완료된 후**에 이뤄져야 합니다.

## 2. 구현

1. Android와 iOS 모두 배포된 경우 플랫폼 별로 발급받은 Ad Unit ID를 입력합니다.
2. 필요한 콜백을 등록합니다.
3. `AdxSdk.loadInterstitial()` 를 호출하여 광고를 로드합니다.
4. 광고 객체 해지시 `AdxSdk.destroyInterstitial()` 를 호출합니다.

```dart
String adUnitId = Platform.isAndroid ? "<ANDROID_ADX_INTERSTITIAL_AD_UNIT_ID>" : "<IOS_ADX_INTERSTITIAL_AD_UNIT_ID>";

AdxSdk.setInterstitialListener(InterstitialAdListener(
  onAdLoaded: (){
  },
  onAdError: (int errorCode){
  },
  onAdImpression: (){
  },
  onAdClicked: (){
  },
  onAdClosed: (){
  },
  onAdFailedToShow: (){
  })
);

AdxSdk.loadInterstitial(adUnitId);
```

* 광고가 로드가 되면 `showInterstitial()` 를 호출하여 광고를 표출합니다.

```csharp
bool isLoaded = (await AdxSdk.isInterstitialLoaded(adUnitId))!;
if (isLoaded) {
    AdxSdk.showInterstitial(adUnitId);
}
```

* 광고 객체 해지시 `destroyInterstitial()` 를 호출합니다.

```dart
@override
void dispose() {
  super.dispose();
  AdxSdk.destroyInterstitial(adUnitId);
}
```

## 3. Callback

특정 이벤트를 수신할 수 있습니다. 필요에 따라 구현해주세요.

```dart
class InterstitialAdListener {

  void Function() onAdLoaded;
  void Function(int errorCode) onAdError;
  void Function() onAdImpression;
  void Function() onAdClicked;
  void Function() onAdClosed;
  void Function() onAdFailedToShow;

  InterstitialAdListener({
      required this.onAdLoaded,
      required this.onAdError,
      required this.onAdImpression,
      required this.onAdClicked,
      required this.onAdClosed,
      required this.onAdFailedToShow
  });
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://platform-business.gitbook.io/adx/flutter/sdk-integration/ad-formats/interstitial-ad.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
