# 전면 비디오 광고

## 1. 인스턴스 생성

AppKey와placementId를 파라미터로 넘겨주고 전면 비디오 광고 관련 인스턴스를 생성한다.

{% code title="JavaScript" %}

```javascript
RNAdPopcornInterstitialVideoAdModule.createInstance('YOUR_APP_KEY', 'PLACEMENT_ID');
```

{% endcode %}

## 2. 광고 요청

전면 비디오  광고 노출을 원하는 시점에 <mark style="color:red;">`loadAd()`</mark> API를 호출하여 서버에 광고를 요청합니다.

{% code title="JavaScript" %}

```javascript
RNAdPopcornInterstitialVideoAdModule.loadAd('PLACEMENT_ID');
```

{% endcode %}

## 3. 광고 노출

전면 비디오광고 노출 시점에 <mark style="color:red;">`showAd()`</mark> API를 추가하여 광고를 노출합니다.

{% code title="JavaScript" %}

```javascript
RNAdPopcornInterstitialVideoAdModule.showAd('PLACEMENT_ID');
```

{% endcode %}

## 4. 이벤트 연동

{% code title="JavaScript" %}

```javascript
componentDidMount() {
    ...
    const eventEmitter = new NativeEventEmitter();
    eventEmitter.addListener('OnInterstitialVideoAdLoaded', (event) => {
            console.log('OnInterstitialVideoAdLoaded event : ' + event.placementId);
            }
        );
    ...
  }
```

{% endcode %}

| 이벤트                                                               | 설명                    |
| ----------------------------------------------------------------- | --------------------- |
| <mark style="color:red;">`OnInterstitialVideoAdLoaded`</mark>     | 전면 비디오 로딩 성공          |
| ㄴevent.placementId                                                | 전면 비디오 로딩 성공한 지면 키    |
| <mark style="color:red;">`OnInterstitialVideoAdLoadFailed`</mark> | 전면 비디오 로딩 실패          |
| ㄴevent.placementId                                                | 전면 비디오 로딩 실패한 지면 키    |
| ㄴevent.errorCode                                                  | 전면 비디오 로딩 실패 에러코드     |
| ㄴevent.errorMessage                                               | 전면 비디오 로딩 실패 에러 메시지   |
| <mark style="color:red;">`OnInterstitialVideoAdOpened`</mark>     | 전면 비디오 노출             |
| ㄴevent.placementId                                                | 노출된 전면 비디오 광고 지면 키    |
| <mark style="color:red;">`OnInterstitialVideoAdOpenFalied`</mark> | 전면 비디오 노출 실패          |
| ㄴevent.placementId                                                | 노출 실패한 전면 비디오 광고 지면 키 |
| <mark style="color:red;">`OnInterstitialVideoAdClosed`</mark>     | 전면 비디오 닫기             |
| ㄴevent.placementId                                                | 전면 비디오 광고 닫은 지면 키     |
| <mark style="color:red;">`OnInterstitialVideoAdClicked`</mark>    | 전면 비디오 클릭             |
| ㄴevent.placementId                                                | 전면 비디오 광고 클릭한 지면 키    |

## 5. 샘플 코드

{% code title="JavaScript" %}

```javascript
import React, { useEffect } from 'react';
import {
  NativeModules,
  NativeEventEmitter
} from 'react-native';

const RNAdPopcornInterstitialVideoAdModule= NativeModules.RNAdPopcornInterstitialVideoAdModule;

function App(): JSX.Element {
  const isDarkMode = useColorScheme() === 'dark';

  const backgroundStyle = {
    backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
  };
  RNAdPopcornSSPModule.init();

  RNAdPopcornInterstitialVideoAdModule.createInstance('YOUR_APP_KEY', 'PLACEMENT_ID');
  RNAdPopcornInterstitialVideoAdModule.loadAd('PLACEMENT_ID');

  return (
    <SafeAreaView style={backgroundStyle}>
      <StatusBar
        barStyle={isDarkMode ? 'light-content' : 'dark-content'}
        backgroundColor={backgroundStyle.backgroundColor}
      />

      <ScrollView
        contentInsetAdjustmentBehavior="automatic"
        style={backgroundStyle}>
        <Header />        
      </ScrollView>
    </SafeAreaView>
  );
}


componentDidMount() {
  ...
  const eventEmitter = new NativeEventEmitter();
  eventEmitter.addListener('OnInterstitialVideoAdLoaded', (event) => {
          console.log('OnInterstitialVideoAdLoaded event : ' + event.placementId);
					RNAdPopcornInterstitialVideoAdModule.showAd(event.placementId);
          }
      );
  ...
}
```

{% endcode %}


---

# 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://adpopcornssp.gitbook.io/ssp-sdk/sdk/react-native-beta/undefined-3.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.
