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

# 리워드 비디오 광고

## 1. 인스턴스 생성

{% tabs %}
{% tab title="Objective-C" %}
노출하고자 하는 ViewController.m에 AdPopcornSSPRewardVideoAd.h를 import 하고 인스턴스 변수를 선언 합니다.

```objectivec
@implements AdPopcornSSPRewardVideoADViewController () 					
- (void) viewDidLoad									
{										
    _sspRewardVideoAd = [[AdPopcornSSPRewardVideoAd alloc] initWithKey: @"YOUR_APP_KEY" placementId: @"YOUR_PLACEMENT_Id" viewController:self];							
} 

```

{% endtab %}

{% tab title="Swift" %}
광고를 노출하고자 하는 ViewController.swift 에 AdPopcornSSPInterstitialRewardVideoAd 인스턴스 변수를 생성합니다.

```swift
class ViewController: UIViewController, APSSPRewardVideoAdDelegate
{	
    // RewardVideo
    var rewardVideo: AdPopcornSSPRewardVideoAd!
}
```

{% endtab %}
{% endtabs %}

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

```objectivec
@implementation AdPopcornSSPInterstitialVideoADViewController () 					
- (void) viewDidLoad									
{										
    _sspInterstitialVideoAd = [[AdPopcornSSPInterstitialVideoAd alloc] initWithKey: @"YOUR_APP_KEY" placementId: @"YOUR_PLACEMENT_Id" viewController:self];							
} 
@end
```

{% endtab %}

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

```swift
class ViewController: UIViewController, APSSPRewardVideoAdDelegate
{	
    // RewardVideo
    var rewardVideo: AdPopcornSSPRewardVideoAd!
    override func viewDidLoad() {
        super.viewDidLoad()
	rewardVideo = AdPopcornSSPRewardVideoAd.init(key: "YOUR_APP_KEY", 
	placementId: "YOUR_PLACEMENT_Id", viewController: self)        
    }
}

```

{% endtab %}
{% endtabs %}

### 1) Placement ID 변경

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

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

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

{% endtab %}

{% tab title="Swift" %}

<pre><code><strong>rewardVideo.placementId = "변경하고자 할 ID"
</strong></code></pre>

{% endtab %}
{% endtabs %}

## 2. 리워드 비디오 광고 요청

<mark style="color:red;">`loadRequest`</mark> API를 호출 하여 리워드 비디오 광고를 불러옵니다.

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

```objectivec
[_sspRewardVideoAd loadRequest];
```

{% endtab %}

{% tab title="Swift" %}

<pre class="language-swift"><code class="lang-swift"><strong>rewardVideo.loadRequest()
</strong></code></pre>

{% endtab %}
{% endtabs %}

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

## 3. 리워드 비디오 광고 노출

{% tabs %}
{% tab title="Objective-C" %} <mark style="color:red;">`presentFromViewController`</mark> API를 호출하여 리워드 비디오 광고를 불러옵니다.

```objectivec
[_sspRewardVideoAd presentFromViewController:self];
```

{% endtab %}

{% tab title="Swift" %} <mark style="color:red;">`present API`</mark>를 호출하여 전면 비디오 광고를 불러옵니다.

```swift
rewardVideo.present(from:self)
```

{% endtab %}
{% endtabs %}

## 4. 델리게이트 설정

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

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

{% tabs %}
{% tab title="Objective-C" %}
\_sspRewardVideoAd 인스턴스에 delegate를 설정하고 구현하여야 합니다.

| delegate                          | 설명                                                                 |
| --------------------------------- | ------------------------------------------------------------------ |
| APSSPRewardVideoAdLoadSuccess     | 비디오광고 로드 성공                                                        |
| APSSPRewardVideoAdLoadFail, error | 비디오광고 로드 실패. [에러코드 값](/ssp-sdk/sdk/ios/ios-3.1.0+/undefined-12.md) |
| APSSPRewardVideoAdShowSuccess     | 비디오광고 노출 성공                                                        |
| APSSPRewardVideoAdShowFail        | 비디오광고 노출 실패                                                        |
| APSSPRewardVideoAdClosed          | 비디오광고 닫기                                                           |
| APSSPRewardVideoAdPlayCompleted   | 비디오광고 APSSP 재생 완료                                                  |
| APSSPRewardPlusCompleteResult     | 리워드 플러스 활성화 된 유저의 경우 포인트 적립 요청 결과를 전달                              |

{% endtab %}

{% tab title="Swift" %}
rewardVideo인스턴스에 delegate를 설정하고 구현하여야 합니다.

| delegate                          | 설명                                                                 |
| --------------------------------- | ------------------------------------------------------------------ |
| apsspRewardVideoAdLoadSuccess     | 비디오광고 로드 성공                                                        |
| apsspRewardVideoAdLoadFail(error) | 비디오광고 로드 실패. [에러코드 값](/ssp-sdk/sdk/ios/ios-3.1.0+/undefined-12.md) |
| apsspRewardVideoAdShowSuccess     | 비디오광고 노출 성공                                                        |
| apsspRewardVideoAdShowFail        | 비디오광고 노출 실패                                                        |
| apsspRewardVideoAdClosed          | 비디오광고 닫기                                                           |
| apsspRewardVideoAdPlayCompleted   | 비디오광고 재생 완료                                                        |
| apsspRewardPlusCompleteResult     | 리워드 플러스 활성화 된 유저의 경우 포인트 적립 요청 결과를 전달                              |
| {% endtab %}                      |                                                                    |
| {% endtabs %}                     |                                                                    |

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

```objectivec
#import "AdPopcornSSPRewardVideoADViewController.h
						
@interface AdPopcornSSPRewardVideoADViewController() <APSSPRewardVideoAdDelegate>		
@end											
											
@implementation AdPopcornSSPRewardVideoADViewController						
											
   - (void)viewDidLoad 
   {															
       [super viewDidLoad];																		
       // 리워드 광고 델리게이트 설정								
       _sspRewardVideoAd.delegate = self;								
   }											
   						
   // 리워드 광고 델리게이트 구현									
   - (void)APSSPRewardVideoAdLoadSuccess:(AdPopcornSSPRewardVideoAD *)rewardVideoAd;						
   {												
      [_sspRewardVideoAd presentFromViewController:self];						
   }											
   						
   - (void)APSSPRewardVideoAdLoadFail:(AdPopcornSSPRewardVideoAd *)rewardVideoAd error:(AdPopcornSSPError)error			
   {													
   }			
   	
   - (void)APSSPRewardVideoAdShowSuccess:(AdPopcornSSPRewardVideoAD *)rewardVideoAd				
   {												
   }		
   		
   - (void)APSSPRewardVideoAdShowFail:(AdPopcornSSPRewardVideoAd *)rewardVideoAd							
   {												
   }		
   		
   - (void)APSSPRewardVideoAdClosed:(AdPopcornSSPRewardVideoAD *)rewardVideoAd							
   {													
   }		
   		
   - (void)APSSPRewardVideoAdPlayCompleted:(AdPopcornSSPRewardVideoAd)rewardVideoAd adNetworkNo:(long)adNetworkNo completed:(BOOL)completed
   {	   
        // 네트워크 ID List
        // 0: 애드팝콘
        // 1: AdMob
        // 7: UnityAds
        // 8: Mintegral
        // 13: AdColony
        // 14: Vungle
        // 16: Fyber
        // 17: TapJoy										     
   }	
   
   - (void)APSSPRewardPlusCompleteResult:(BOOL)result resultCode:(int)resultCode rewar:(int)reward							
   {													
   }										
@end	
```

{% endtab %}

{% tab title="Swift" %}

```swift
class ViewController: UIViewController, APSSPRewardVideoAdDelegate
{	
    // RewardVideo
    var rewardVideo: AdPopcornSSPRewardVideoAd!

    override func viewDidLoad() {
        super.viewDidLoad()
	rewardVideo = AdPopcornSSPRewardVideoAd.init(key: "YOUR_APP_KEY", 
	placementId: "YOUR_PLACEMENT_Id", viewController: self)     
	rewardVideo.delegate = self   
    }
		
    // RewardVideo Delegate
    func apsspRewardVideoAdLoadSuccess(_ rewardVideoAd: AdPopcornSSPRewardVideoAd!) {
        rewardVideo.present(from: self)
    }
    func apsspRewardVideoAdLoadFail(_ rewardVideoAd: AdPopcornSSPRewardVideoAd!, error: AdPopcornSSPError!) {
    }
    func apsspRewardVideoAdShowSuccess(_ rewardVideoAd: AdPopcornSSPRewardVideoAd!) {
    }
    func apsspRewardVideoAdShowFail(_ rewardVideoAd: AdPopcornSSPRewardVideoAd!) {
    }
    func apsspRewardVideoAdClosed(_ rewardVideoAd: AdPopcornSSPRewardVideoAd!) {
    }
    func apsspRewardVideoAdPlayCompleted(_ rewardVideoAd: AdPopcornSSPRewardVideoAd!, adNetworkNo: Int, completed: Bool) {
        // 기존 미디에이션 업체 별로 completed 이벤트가 발생하던 구조에서 이 delegate 하나로 통합되었으며, adNetworkNo를 통해 어느 업체에서 완료가 발생하였는지 확인 가능.
        // 네트워크 ID List
        // 0: 애드팝콘
        // 1: AdMob
        // 7: UnityAds
        // 8: Mintegral
        // 13: AdColony
        // 14: Vungle
        // 16: Fyber
        // 17: TapJoy
    }
    func apsspPRewardPlusCompleteResult(_ result: Bool, resultCode: Int, reward: Int)							
   {													
   }
}
```

{% endtab %}
{% endtabs %}

## 5. 유저 식별값 입력

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

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

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

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

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

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

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

{% endtab %}

{% tab title="Swift" %}

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

{% endtab %}
{% endtabs %}

## 6. 리워드 비디오 CS 페이지 호출

리워드 비디오 관련 CS 접수 페이지를 노출 시키기 위해서는 <mark style="color:red;">`openCSViewController`</mark> API를 호출하여 줍니다.

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

```objectivec
[AdPopcornSSP.openCSViewController:self appKey:@"YOUR_APP_KEY" userId:@"usn"];
```

{% endtab %}

{% tab title="Swift" %}

```swift
AdPopcornSSP.openCSViewController(self, appKey: "YOUR_APP_KEY", userId: "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-4.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.
