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

# 전면 광고

## 1. 인스턴스 생성

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

<pre class="language-objectivec"><code class="lang-objectivec"><strong>#import &#x3C;AdPopcornSSP/AdPopcornSSPInterstitialAd.h>
</strong>
@interface AdPopcornSSPInterstitialADViewController () &#x3C;AdPopcornSSPInterstitialAdDelegate>
{ 
    AdPopcornSSPInterstitialAd *_sspInterstitialAd;
}
@end
</code></pre>

{% endtab %}

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

```swift
class ViewController: UIViewController, APSSPInterstitialAdDelegate
{	
    // Interstitial
    var interstitialAd: AdPopcornSSPInterstitialAd!
}
```

{% endtab %}
{% endtabs %}

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

```objectivec
@implementation AdPopcornSSPInterstitialADViewController 

- (void)viewDidLoad { 
  [super viewDidLoad]; 

  _sspInterstitialAd = [[AdPopcornSSPInterstitialAd alloc] initWithKey:@"YOUR_APP_KEY" placementId:@"YOUR_PLACEMENT_Id" viewController:self];
}
@end
```

{% endtab %}

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

```swift
class ViewController: UIViewController, APSSPInterstitialAdDelegate
{
// Interstitial
    var interstitialAd: AdPopcornSSPInterstitialAd!

    override func viewDidLoad() {
        super.viewDidLoad()
	interstitialAd = AdPopcornSSPInterstitialAd.init(key: "YOUR_APP_KEY", 
	placementId: "YOUR_PLACEMENT_Id", viewController: self)        
    }
}
```

{% endtab %}
{% endtabs %}

### 1) Placement ID 변경

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

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

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

{% endtab %}

{% tab title="Swift" %}

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

{% endtab %}
{% endtabs %}

## 2. 광고 요청

<mark style="color:red;">`loadRequest`</mark> API를 호출하여 전면 광고를 불러옵니다.

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

```objectivec
[_sspInterstitialAd loadRequest];
```

{% endtab %}

{% tab title="Swift" %}

```swift
interstitialAd.loadRequest()
```

{% endtab %}
{% endtabs %}

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

## 3. 광고 노출

<mark style="color:red;">`presentFromViewController`</mark> API(present API)를 호출하여 전면광고를 노출합니다.

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

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

{% endtab %}

{% tab title="Swift" %}

```swift
interstitialAd.present(from: self);
```

{% endtab %}
{% endtabs %}

## 4. 광고 배경색 변경

전면 광고가 나오는 뷰의 빈 공간에 배경색을 채울 수 있습니다.&#x20;

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

<pre class="language-objectivec"><code class="lang-objectivec"><strong>// default : [UIColor colorWithRed:0 green:0 blue:0 alpha:0.8] 
</strong><strong>_sspInterstitialAd.backgroundColor = [UIColor redColor]; 
</strong></code></pre>

{% endtab %}

{% tab title="Swift" %}

```swift
// default : UIColor(red: 0, green: 0, blue: 0, alpha: 0.8)
interstitialAd.backgroundColor = UIColor.blue
```

{% endtab %}
{% endtabs %}

## 5. 델리게이트

전면광고에서 발생하는 이벤트에 대한 델리게이트를 제공합니다. 델리게이트를 사용하기 위해서는 <mark style="color:red;">`APSSPInterstitialAdDelegate`</mark>를 추가하여야 합니다.

* Objective-C 의 경우 \_sspInterstitialAd 인스턴스에 delegate를 설정하고 구현하여야 하며,
* Swift 의 경우 interstitialAd 인스턴스에 delegate를 설정하고 구현하여야 합니다.

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

| delegate                       | 설명                                                                |
| ------------------------------ | ----------------------------------------------------------------- |
| APSSPInterstitialAdLoadSuccess | 전면광고 로드 성공                                                        |
| APSSPInterstitialAdLoadFail    | 전면광고 로드 실패. [에러코드 값](/ssp-sdk/sdk/ios/ios-3.1.0+/undefined-12.md) |
| APSSPInterstitialAdShowSuccess | 전면 광고 노출 성공                                                       |
| APSSPInterstitialAdShowFail    | 전면 광고 노출 실패                                                       |
| APSSPInterstitialAdClosed      | 전면광고 닫기                                                           |
| APSSPInterstitialAdClicked     | 전면광고 클릭                                                           |
| {% endtab %}                   |                                                                   |

{% tab title="Swift" %}

| delegate                       | 설명                                                                |
| ------------------------------ | ----------------------------------------------------------------- |
| apsspInterstitialAdLoadSuccess | 전면광고 로드 성공                                                        |
| apsspInterstitialAdLoadFail    | 전면광고 로드 실패. [에러코드 값](/ssp-sdk/sdk/ios/ios-3.1.0+/undefined-12.md) |
| apsspInterstitialAdShowSuccess | 전면 광고 노출 성공                                                       |
| apsspInterstitialAdShowFail    | 전면 광고 노출 실패                                                       |
| apsspInterstitialAdClosed      | 전면광고 닫기                                                           |
| apsspInterstitialAdClicked     | 전면광고 클릭                                                           |
| {% endtab %}                   |                                                                   |
| {% endtabs %}                  |                                                                   |

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

```objectivec
#import "AdPopcornSSPInterstitialADViewController.h"

@interface AdPopcornSSPInterstitialADViewController() <APSSPInterstitialAdDelegate>

@end

@implementation AdPopcornSSPInterstitialADViewController
  - (void)viewDidLoad { 
    [super viewDidLoad]; 
  
    // 전면광고 델리게이트 설정 
    _sspInterstitialAd.delegate = self;
  }
  
  //전면광고 델리게이트 구현
  -(void)APSSPInterstitialAdLoadSuccess:(AdPopcornSSPInterstitialAd *)interstitialAd
  { 
  }
  
  -(void)APSSPInterstitialAdLoadFail:(AdPopcornSSPInterstitialAd *)interstitialAd error:(AdPopcornSSPError *)error
  { 
  
  }
  
  -(void)APSSPInterstitialAdClosed:(AdPopcornSSPInterstitialAd *)interstitialAd
  {
  }
  
  -(void)APSSPInterstitialAdClicked:(AdPopcornSSPInterstitialAd *)interstitialAd
  { 
  }

@end
```

{% endtab %}

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

```swift
class ViewController: UIViewController, APSSPInterstitialAdDelegate
{	
		// Interstitial
    var interstitialAd: AdPopcornSSPInterstitialAd!

    override func viewDidLoad() {
        super.viewDidLoad()
	interstitialAd = AdPopcornSSPInterstitialAd.init(key: "YOUR_APP_KEY", 
	placementId: "YOUR_PLACEMENT_Id", viewController: self)
        interstitialAd.delegate = self
    }

		// Interstitial Delegate
    func apsspInterstitialAdLoadSuccess(_ interstitialAd: AdPopcornSSPInterstitialAd!) {
        interstitialAd.present(from: self);
    }
    func apsspInterstitialAdLoadFail(_ interstitialAd: AdPopcornSSPInterstitialAd!, error: AdPopcornSSPError!) {
    }
    func apsspInterstitialAdShowSuccess(_ interstitialAd: AdPopcornSSPInterstitialAd!) {
    }
    func apsspInterstitialAdShowFail(_ interstitialAd: AdPopcornSSPInterstitialAd!, error: AdPopcornSSPError!) {
    }
    func apsspInterstitialAdClosed(_ interstitialAd: AdPopcornSSPInterstitialAd!) {
    }
    func apsspInterstitialAdClicked(_ interstitialAd: AdPopcornSSPInterstitialAd!) {
    }
}
```

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