> 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-8.md).

# 팝콘텐츠 광고

{% hint style="info" %}
팝콘텐츠 광고는 <mark style="color:red;">`v2.9.0`</mark> 버전부터 지원합니다.
{% endhint %}

{% hint style="danger" %}
콘텐츠 광고를 노출 시키고자 할 경우, 반드시 IDFA 설정과 유저 식별값 설정을 진행해 주어야 합니다.
{% endhint %}

## 1. IDFA 설정

아래 링크에서 IDFA 설정에 대해서 확인 후 진행해주세요.

[\[애드팝콘 SSP iOS IDFA 설정\]](/ssp-sdk/sdk/ios/ios-2.x.x/undefined.md#id-3)

## 2. 유저 식별값 입력

유저 식별값은 팝콘텐츠 광고 페이지내 광고 완료 시 완료유저를 식별하기 위해 사용되는 값입니다.

{% hint style="warning" %} <mark style="color:red;">**주의사항**</mark>

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

위 주의사항에 유의하여 유저 식별값을 입력합니다.

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

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

{% endtab %}

{% tab title="Swift" %}

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

{% endtab %}
{% endtabs %}

## 3. 인스턴스 생성

{% tabs %}
{% tab title="Objective-C" %}
MainViewController.m에 AdPopcornSSPPopContentsAd.h 를 import 하고 인스턴스 변수를 선언합니다.

```objectivec
#import <AdPopcornSSP/AdPopcornSSPPopContentsAd.h>

@interface MainViewController() <APSSPPopContentsAdDelegate>
{ 
    AdPopcornSSPPopContentsAd *_sspPopContentsAd;
}
@end
```

{% endtab %}

{% tab title="Swift" %}
MainViewController.swift 에 AdPopcornSSPPopContentsAd 인스턴스 변수를 선언합니다.

```swift
class MainViewController: UIViewController, APSSPPopContentsAdDelegate
{	
    // AdPopcornSSPPopContentsAd
    var sspPopContentsAd: AdPopcornSSPPopContentsAd!
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Objective-C" %}
MainViewController.m 을 수정하여 생성한 인스턴스를 구현합니다.

```objectivec
@implementation MainViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    [AdPopcornSSP.setUserId:@"TEST_USN"];
    _sspPopContentsAd = [[AdPopcornSSPPopContentsAd alloc] initWithAppKey:@"YOUR_APPKEY" contentsPlacementId:@"YOUR_POPCONTENTS_PLACEMENT_ID" viewController:self];
    _sspPopContentsAd.delegate = self;
    [_sspPopContentsAd openPopContents];
}
@end
```

{% endtab %}

{% tab title="Swift" %}
MainViewController.swift 을 수정하여 생성한 인스턴스를 구현합니다.

```swift
class MainViewController: UIViewController, APSSPPopContentsAdDelegate
{	
    // AdPopcornSSPContentsAd 
    var sspContentsAd : AdPopcornSSPContentsAd!
    override func viewDidLoad() {
        super.viewDidLoad()
        AdPopcornSSP.setUserId("TEST_USN")
	sspPopContentsAd = AdPopcornSSPPopContentsAd.initWithAppKey(key: "YOUR_APPKEY", contentsPlacementId: "YOUR_CONTENTS_PLACEMENT_ID", viewController: self)      
	sspPopContentsAd.delegate = self
    }
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
appKey, contentsPlacementId 의 경우 애드팝콘 사업팀(<mark style="color:blue;"><monetize@adpopcorn.com></mark>)을 통해 발급 받으시기 바랍니다
{% endhint %}

## 4. 팝콘텐츠 페이지 오픈

<mark style="color:red;">`openPopContents`</mark> API를 호출하여 콘텐츠 페이지를 오픈합니다.

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

```objectivec
[_sspPopContentsAd openPopContents];
```

{% endtab %}

{% tab title="Swift" %}

```swift
_sspPopContentsAd.openPopContents();
```

{% endtab %}
{% endtabs %}

## 5. 팝콘텐츠 이벤트 리스너

팝콘텐츠 광고에서 발생하는 이벤트를 받고자 할 경우 , 이벤트 리스너를 생성하여 전달해 줍니다.

이벤트 리스너를 통해 들어오는 이벤트들을 아래와 같습니다.

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

<table><thead><tr><th width="307">delegate</th><th>설명</th></tr></thead><tbody><tr><td>APSSPPopContentsAdOpenSuccess</td><td>팝콘텐츠 광고 페이지 오픈 성공</td></tr><tr><td>APSSPPopContentsAdOpenFail, error</td><td>팝콘텐츠 광고 페이지 오픈 실패. <a href="/pages/qEliH2tRuJF6CW2rnJU1">에러코드 값</a></td></tr><tr><td>APSSPPopContentsAdClosed</td><td>팝콘텐츠 광고 페이지 닫음</td></tr></tbody></table>
{% endtab %}

{% tab title="Swift" %}

<table><thead><tr><th width="299">delegate</th><th>설명</th></tr></thead><tbody><tr><td>apsspPopContentsAdOpenSuccess</td><td>팝콘텐츠 광고 페이지 오픈 성공</td></tr><tr><td>apsspPopContentsAdOpenFail(error)</td><td>팝콘텐츠 광고 페이지 오픈 실패. <a href="/pages/qEliH2tRuJF6CW2rnJU1">에러코드 값</a></td></tr><tr><td>apsspPopContentsAdClosed</td><td>팝콘텐츠 광고 페이지 닫음</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

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

```objectivec
#pragma mark APSSPPopContentsAdDelegate
- (void)APSSPPopContentsAdOpenSuccess:(AdPopcornSSPPopContentsAd *)popContentsAd
{
}

- (void)APSSPPopContentsAdOpenFail:(AdPopcornSSPPopContentsAd *)popContentsAd error:(AdPopcornSSPError *)error
{
}

- (void)APSSPPopContentsAdClosed:(AdPopcornSSPPopContentsAd *)popContentsAd
{
    
}
```

{% endtab %}

{% tab title="Swift" %}

```swift
// APSSPPopContentsAdDelegate
func apsspPopContentsAdOpenSuccess(_ popContentsAd: AdPopcornSSPPopContentsAd!) {
}
func apsspPopContentsAdOpenFail(_ popContentsAd: AdPopcornSSPPopContentsAd!, error: AdPopcornSSPError!) {
}
func apsspPopContentsAdClosed(_ popContentsAd: AdPopcornSSPPopContentsAd!) {
}
```

{% 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-8.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.
