# Flutter용 인터스티셜 광고 통합

> 정적 광고와 동영상 포맷을 모두 지원하는 Unity 레벨플레이 SDK를 사용하여 전체 화면 인터스티셜 광고 Flutter 앱에 통합합니다.

레벨플레이 인터스티셜 광고 전체 화면 광고 유닛으로, 일반적으로 앱 라이프사이클 동안 자연스러운 전환 지점에서 게재됩니다. Unity 정적 삽입과 비디오 삽입을 모두 지원합니다.

> **Note:**
>
> 이 기술 자료는 SDK 8.4.0 이상에 해당합니다.

## 필수 조건##prerequisites

* 레벨플레이 플러그인을 앱에 올바르게 [통합했는지 확인](/grow/levelplay/sdk/flutter/plugin-integration.md)합니다.
* 레벨플레이 초기화 API 사용하여 SDK를 초기화해야 합니다.
* 레벨플레이 대시보드에서 AdUnitID를 찾습니다.

## 인터스티셜 광고 만들기 및 이벤트 등록##create-interstitial-and-register-to-events

`onInitSuccess` 콜백을 수신한 후 인터스티셜 광고 오브젝트를 생성합니다.

레벨플레이 SDK는 인터스티셜 광고 활동을 알려주는 여러 이벤트를 발생시킵니다. 이러한 이벤트를 수신하려면 광고 유닛의 리스너를 등록합니다. SDK를 초기화하기 전에 정보를 손실하지 않도록 리스너를 설정해야 합니다.

```dart
final LevelPlayInterstitialAd _interstitialAd = LevelPlayInterstitialAd(adUnitId: [YOUR_AD_UNIT]);

@override
void initState() {
    super.initState();
    _interstitialAd.setListener(this);
}
```

## 인터스티셜 광고 리스너 설정##set-interstitial-listener

광고 전송에 대해 알리기 위해 코드에 `LevelPlayInterstitialAdListener`를 구현하십시오.

* 권장되는 베스트 프랙티스는 인터스티셜 광고 광고를 로드하기 전에 리스너를 설정하는 것입니다.
* 각 인터스티셜 광고 광고에는 고유한 리스너 구현이 있어야 합니다.
* 콜백은 메인 스레드 실행됩니다.

```dart
  @override
  void onAdLoaded(LevelPlayAdInfo adInfo) {
    // Provided when the ad is successfully loaded
  }
  @override
  void onAdLoadFailed(LevelPlayAdError error) {
    // Provided when the ad fails to load. 광고 유닛 정보가 포함됩니다.
  }
  @override
  void onAdDisplayed(LevelPlayAdInfo adInfo) {
    // Provided when the ad is displayed. 이는 노출과 동일합니다.
  }
  @override
  void onAdDisplayFailed(LevelPlayAdError error, LevelPlayAdInfo adInfo) {
    // Provided when the ad fails to be displayed
  }
  
  @override
  void onAdClicked(LevelPlayAdInfo adInfo) {
    // Provided when the user clicks on the ad
  }
  @override
  void onAdClosed(LevelPlayAdInfo adInfo) {
    // Provided when the ad is closed
  }
  @override
  void onAdInfoChanged(LevelPlayAdInfo adInfo) {
    // Provided when the ad info is updated. 다른 광고가 로드되었을 때 사용 가능하며 더 높은 CPM/Rate를 포함합니다.
  }
```

## 인터스티셜 광고 로드##load-interstitial-ad

인터스티셜 광고를 로드하려면 `loadAd`를 사용합니다.

```dart
_interstitialAd.loadAd();
```

## 인터스티셜 광고 표시##show-interstitial-ad

`showAd`를 사용하여 `onAdLoaded` 콜백을 수신한 후 인터스티셜 광고를 표시합니다.

* 공유하는 데 필요한 **활동**입니다. 
* 플레이스먼트를 사용하는 경우 아래의 플레이스먼트 섹션에 표시된 대로 **showAd** API에서 플레이스먼트 이름을 전달합니다.
* 광고가 사용자 성공적으로 표시되면 로딩 단계를 반복하여 다른 광고를 로드할 수 있습니다. 

```dart
// Show ad without placement 
_interstitialAd.showAd(); 
// Show ad with placement 
_interstitialAd.showAd(placement: [YOUR_PLACEMENT]);
```

### 광고가 준비되었는지 확인##check-ad-is-ready

표시 실패를 방지하고 광고가 올바르게 작동했는지 확인하기 위해 다음 API를 사용하여 `showAd` API를 호출하는 것이 좋습니다.

* `isAdReady`: 광고가 성공적으로 로드되고 광고 유닛이 제한되지 않거나 거짓이면 true를 반환합니다.

* `isPlacementCapped`: 유효한 플레이스먼트가 제한되면 true를 반환합니다. 플레이스먼트가 유효하지 않거나 제한이 없는 경우 이 API false를 반환합니다.

```dart
// Check that ad is ready and that the placement is not capped 
if(_interstitialAd.isAdReady() && !LevelPlayInterstitialAd.isPlacementCapped([YOUR_PLACEMENT])) { 
    _interstitialAd.showAd(placement:[YOUR_PLACEMENT]); 
}
```

### Placements##placements

Unity는 레벨플레이 대시보드에서 인터스티셜 광고의 [플레이스먼트 속도](/grow/levelplay/platform/settings/placements.md) 및 한도를 지원합니다. 

인터스티셜 광고에 대한 플레이스먼트를 설정한 경우 특정 플레이스먼트에 광고를 게재하려면 `showAd` 메서드를 호출합니다.

```dart
// Check that ad is ready and that the placement is not capped 
if(_interstitialAd.isAdReady() && !LevelPlayInterstitialAd.isPlacementCapped([YOUR_PLACEMENT])) { 
    _interstitialAd.showAd(placement:[YOUR_PLACEMENT]); 
}
```

## 인터스티셜 광고 전체 구현 예시##full-implementation-example-of-interstitial-ads

```dart
// Start of the widget...
final LevelPlayInterstitialAd _interstitialAd = LevelPlayInterstitialAd(adUnitId: 'YOUR_AD_UNIT_ID');
  @override
  void initState() {
    super.initState();
    _interstitialAd.setListener(this);
    _interstitialAd.loadAd();
  }
  @override
  void onAdClicked(LevelPlayAdInfo adInfo) {
    // Implement your logic here...
  }
  @override
  void onAdClosed(LevelPlayAdInfo adInfo) {
    // Implement your logic here...
  }
  @override
  void onAdDisplayFailed(LevelPlayAdError error, LevelPlayAdInfo adInfo) {
    // Implement your logic here...
  }
  @override
  void onAdDisplayed(LevelPlayAdInfo adInfo) {
    // Implement your logic here...
  }
  @override
  void onAdInfoChanged(LevelPlayAdInfo adInfo) {
    // Implement your logic here...
  }
  @override
  void onAdLoadFailed(LevelPlayAdError error) {
    // Implement your logic here...
  }
  @override
  void onAdLoaded(LevelPlayAdInfo adInfo) {
    // Implement your logic here, for example showing the ad
    _interstitialAd.showAd();
  }
  // Rest of the widget
  // End of widget...
```

## 레벨플레이 Mediation 데모 앱##levelplay-mediation-demo-app

통합 데모 애플리케이션 앱에 인터스티셜 광고 광고 유닛 API를 통합하는 방법을 보여 줍니다.

[Flutter 데모 애플리케이션 다운로드](https://github.com/ironsource-mobile/Flutter-SDK/tree/master/example)

[Integration Test Suite](/grow/levelplay/sdk/flutter/integration-test-suite/.md)와의 연동을 확인합니다.

## 다음 단계##next-steps

추가 인터스티셜 광고 광고 네트워크를 연동하거나 추가 광고 형식을 설정 Flutter 연동 가이드를 따르십시오.

* [Mediation Networks 추가](/grow/levelplay/sdk/flutter/mediation-networks.md)
* [보상형 광고](/grow/levelplay/sdk/flutter/rewarded-ads-integration.md)
* [배너 광고](/grow/levelplay/sdk/flutter/banner-integration.md)
* [네이티브 광고](/grow/levelplay/sdk/flutter/native-ads-integration.md)
