> For the complete documentation index, see [llms.txt](https://adpopcornssp.gitbook.io/ssp-sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://adpopcornssp.gitbook.io/ssp-sdk/sdk/ios/ios-2.x.x/undefined-5.md).

# 비디오 믹스 광고

## 1. 비디오 믹스 광고 인스턴스 설정

아래 코드를 추가하여 비디오 믹스 광고 인스턴스를 생성합니다.

{% tabs %}
{% tab title="Objective-C" %}

```objectivec
#import "AdPopcornSSPVideoMixAd.h"
     	
@interface AdPopcornSSPVideoMixADViewController()  <APSSPVideoMixAdDelegate> {
}
@end

@implements AdPopcornSSPVideoMixADViewController ()

     AdPopcornSSPVideoMixAd *_sspVideoMixAd;
		
- (void) viewDidLoad									
{
     _sspVideoMixAd = [[AdPopcornSSPVideoMixAd alloc] initWithKey:@"your_app_key" placementId:@"your_placementId" viewController:self];
     _sspVideoMixAd.delegate = self;

}
```

{% endtab %}

{% tab title="Swift" %}

```swift
var videoMixAd : AdPopcornSSPVideoMixAd!
     	
class ViewController: UIViewController, APSSPVideoMixAdDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
        videoMixAd = AdPopcornSSPVideoMixAd(key: "your_app_key", placementId: "your_placementId", viewController: self)
        videoMixAd.delegate = self
    }
}


        
```

{% endtab %}
{% endtabs %}

### 1) Placement ID 변경

비디오 믹스 인스턴스 생성 시 사용한 placementID를 변경하고자 할 경우, 아래와 같은 방식으로 변경합니다.

{% tabs %}
{% tab title="Objective-C" %}

```objectivec
_sspVideoMixAd.placementId = @"변경하고자 할 ID";
```

{% endtab %}

{% tab title="Swift" %}

```swift
videoMixAd.placementId = "변경하고자 할 ID"
```

{% endtab %}
{% endtabs %}

## 2. 비디오 믹스 광고 요청

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

{% hint style="warning" %}
loadAd 호출에 대한 결과로 광고 수신에 실패한 경우에는 loadAd 재호출을 하시면 안됩니다. 과도한 광고 요청 api 호출은 block 사유가 됩니다.
{% endhint %}

{% tabs %}
{% tab title="Objective-C" %}

```swift
[_sspVideoMixAd loadRequest];
```

{% endtab %}

{% tab title="Swift" %}

```kotlin
videoMixAd.loadRequest()
```

{% endtab %}
{% endtabs %}

## 3. 비디오 믹스 광고 노출

광고 노출 시점에 <mark style="color:red;">`present`</mark> API를 추가하여 광고를 재생 합니다.

{% tabs %}
{% tab title="Objective-C" %}

```swift
[_sspVideoMixAd presentFromViewController:self];
```

{% endtab %}

{% tab title="Swift" %}

```kts
videoMixAd.present(from: self)
```

{% endtab %}
{% endtabs %}

## 4. 델리게이트 설정

리워드 비디오 광고에서 발생하는 이벤트에 대한 델리게이트를 제공 합니다.

델리게이트를 사용하기 위해서는 <mark style="color:red;">`APSSPVideoMixAdDelegate`</mark>를 추가 하여야 합니다.

{% tabs %}
{% tab title="Objective-C" %}

<table><thead><tr><th width="467">이벤트 리스너</th><th>설명</th></tr></thead><tbody><tr><td>APSSPVideoMixAdLoadSuccess</td><td>광고 로딩 성공</td></tr><tr><td>  ㄴ videoMixAdType</td><td>2: 전면, 4: 리워드 비디오, 6 : 전면 비디오</td></tr><tr><td>APSSPVideoMixAdLoadFail</td><td>광고 로딩 실패. <a href="/pages/8mnPYzYSU61QOImC3VmQ">에러코드 값</a></td></tr><tr><td>APSSPVideoMixAdShowSuccess</td><td>광고 노출 성공</td></tr><tr><td>APSSPVideoMixAdShowFail</td><td>광고 노출 실패</td></tr><tr><td>APSSPVideoMixAdClosed</td><td>광고 닫기</td></tr><tr><td>  ㄴ videoMixAdType</td><td>2: 전면, 4: 리워드 비디오, 6 : 전면 비디오</td></tr><tr><td>APSSPVideoMixAdPlayCompleted</td><td>비디오 광고 재생 완료</td></tr><tr><td>  ㄴ adNetworkNo</td><td>완료된 미디에이션</td></tr><tr><td>  ㄴ completed</td><td>리워드 비디오 시청 정상 완료 여부</td></tr></tbody></table>
{% endtab %}

{% tab title="Swift" %}

<table><thead><tr><th width="467">이벤트 리스너</th><th>설명</th></tr></thead><tbody><tr><td>apsspVideoMixAdLoadSuccess</td><td>광고 로딩 성공</td></tr><tr><td>  ㄴ type</td><td>2: 전면, 4: 리워드 비디오, 6 : 전면 비디오</td></tr><tr><td>apsspVideoMixAdLoadFail</td><td>광고 로딩 실패. <a href="/pages/8mnPYzYSU61QOImC3VmQ">에러코드 값</a></td></tr><tr><td>apsspVideoMixAdShowSuccess</td><td>광고 노출 성공</td></tr><tr><td>apsspVideoMixAdShowFail</td><td>광고 노출 실패</td></tr><tr><td>apsspVideoMixAdClosed</td><td>광고 닫기</td></tr><tr><td>apsspVideoMixAdPlayCompleted</td><td>비디오 광고 재생 완료</td></tr><tr><td>  ㄴ type</td><td>2: 전면, 4: 리워드 비디오, 6 : 전면 비디오</td></tr><tr><td>  ㄴ adNetworkNo</td><td>완료된 미디에이션</td></tr><tr><td>  ㄴ completed</td><td>리워드 비디오 시청 정상 완료 여부</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Objective-C" %}

```swift
- (void)APSSPVideoMixAdLoadSuccess:(AdPopcornSSPVideoMixAd *)VideoMixAd videoMixAdType: (VideoMixAdType) type {
    
}

- (void)APSSPVideoMixAdLoadFail:(AdPopcornSSPVideoMixAd *)VideoMixAd error:(AdPopcornSSPError *)error {
    
}

- (void)APSSPVideoMixAdShowSuccess:(AdPopcornSSPVideoMixAd *)VideoMixAd {
    
}

- (void)APSSPVideoMixAdShowFail:(AdPopcornSSPVideoMixAd *)VideoMixAd {
    
}

- (void)APSSPVideoMixAdClosed:(AdPopcornSSPVideoMixAd *)VideoMixAd {
    
}

- (void)APSSPVideoMixAdPlayCompleted:(AdPopcornSSPVideoMixAd *)VideoMixAd adNetworkNo:(long) adNetworkNo completed:(BOOL)completed videoMixAdType: (VideoMixAdType) type {
    
}

```

{% endtab %}

{% tab title="Swift" %}

```swift
func apsspVideoMixAdLoadSuccess(_ VideoMixAd: AdPopcornSSPVideoMixAd!, videoMixAdType type: VideoMixAdType) {

}

func apsspVideoMixAdLoadFail(_ VideoMixAd: AdPopcornSSPVideoMixAd!, error: AdPopcornSSPError!) {
    
}

func apsspVideoMixAdShowSuccess(_ VideoMixAd: AdPopcornSSPVideoMixAd!) {
    
}

func apsspVideoMixAdShowFail(_ VideoMixAd: AdPopcornSSPVideoMixAd!) {
    
}

func apsspVideoMixAdClosed(_ VideoMixAd: AdPopcornSSPVideoMixAd!) {
    
}

func apsspVideoMixAdPlayCompleted(_ VideoMixAd: AdPopcornSSPVideoMixAd!, adNetworkNo: Int, completed: Bool, videoMixAdType type: VideoMixAdType) {
    
}
```

{% endtab %}
{% endtabs %}

## 5. 유저 식별값 입력

유저 식별값은 비디오 믹스의 리워드 비디오 광고 타입 시청 완료 시 유저를 식별하기 위해 사용되는 값입니다.

해당 유저 정보를 넘겨주어야 CS 접수 시, 유저를 특정 가능합니다. 단, CS 기능을 오픈하지 않을 경우에는 연동 진행하지 않아도 됩니다.

{% hint style="danger" %}
**주의 사항**

1. 1명의 유저는 1개의 고유한 유저 식별값을 가져야 하며, 가변적인 값을 사용해서는 안됩니다.
2. 개인정보(이메일, 이름, 전화번호, 식별 가능한 유저 아이디 등)이 포함되어서는 안됩니다.
3. 한글, 특수 문자, 공백 등이 포함된 경우에는 반드시 URL 인코딩 처리를 하여 사용하여야 합니다.
4. 유저가 광고 로딩 전에 설정되어야 합니다.
   {% endhint %}

{% tabs %}
{% tab title="Objective-C" %}

```objectivec
[AdPopcornSSP.setUserId:@"TEST_USN"];
```

{% endtab %}

{% tab title="Swift" %}

```swift
AdPopcornSSP.setUserId("TEST_USN")
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://adpopcornssp.gitbook.io/ssp-sdk/sdk/ios/ios-2.x.x/undefined-5.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
