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

# 스플래시 광고

모바일 앱의 스플래시 화면(Splash Screen) 내 광고를 송출하는 형태입니다.

{% hint style="info" %}
스플래시 화면이 되는 ViewController 를 생성한 뒤 MainStory 보드에서 맨 처음 시작하는 ViewController로 세팅해 줍니다.
{% endhint %}

## 1. 인스턴스 생성

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

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

@interface SplashViewController() <APSSPSplashAdDelegate>
{ 
    AdPopcornSSPSplashAd *_sspSplashAd;
}
@end
```

{% endtab %}

{% tab title="Swift" %}
SplashViewController.swift 에 AdPopcornSSPSplashAd 인스턴스 변수를 생성합니다.

```swift
class SplashViewController: UIViewController, APSSPSplashAdDelegate
{	
    // AdPopcornSSPSplashAd
    var splashAd: AdPopcornSSPSplashAd!
}

```

{% endtab %}
{% endtabs %}

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

```objectivec
@implementation SplashViewController 

- (void)viewDidLoad {
    [super viewDidLoad]; 

    _sspSplashAd = [[AdPopcornSSPSplashAd alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) Key:@"YOUR_APP_KEY" placementId:@"YOUR_PLACEMENT_ID" viewController:self];
    [self.view addSubView:_sspSplashAd];
}
@end
```

{% endtab %}

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

```swift
class SplashViewController: UIViewController, APSSPSplashAdDelegate
{	
    // AdPopcornSSPSplashAd
    var splashAd: AdPopcornSSPSplashAd!
    
    override func viewDidLoad() {
        super.viewDidLoad()
	splashAd = AdPopcornSSPSplashAd.init(frame: CGRect(x: 0, y: 0, width: 300, height: 300),
        key: "YOUR_APP_KEY", placementId: "YOUR_PLACEMENT_ID", viewController: self)      
    }
}

```

{% endtab %}
{% endtabs %}

## 2. 광고 타입 설정

아래 코드를 추가하여 스플래시 광고의 타입을 설정 합니다.

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

```objectivec
[_sspSplashAd setFullScreenSplash:YES]; // 기본값 : 일반모드(NO)
```

{% endtab %}

{% tab title="Swift" %}

```swift
splashAd.setFullScreenSplash(false) // 기본값 : 일반모드(false)
```

{% endtab %}
{% endtabs %}

지원 하는 형태의 광고는 총 2가지 이며, 아래 예시와 같이 노출됩니다.

<table><thead><tr><th width="158">광고 타입</th><th>설명</th><th>예시 이미지</th></tr></thead><tbody><tr><td>일반 모드(<mark style="color:red;"><code>:NO</code></mark>, <mark style="color:red;"><code>false</code></mark>)</td><td>정사각형 형태의 광고가 노출됩니다. 이에 로고 하단에 노출시켜줍니다.</td><td><img src="https://50533756-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqmkw7pJLtjFGD5fwChbN%2Fuploads%2FTsfGA44BIya9MzGZuS8v%2Fimage.png?alt=media&amp;token=d90dfb17-86c1-464a-b5c2-7506bb13ed6a" alt="" data-size="original"></td></tr><tr><td>전체 화면 모드(<mark style="color:red;"><code>:YES</code></mark>, <mark style="color:red;"><code>true</code></mark>)</td><td>전체 화면을 채우는 형태의 광고가 노출됩니다.</td><td><img src="https://50533756-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqmkw7pJLtjFGD5fwChbN%2Fuploads%2FczQy1pYklIe3z7aGslmA%2Fimage.png?alt=media&amp;token=b4cc0ac9-3e48-4c8c-9296-1bfac1a1e745" alt="" data-size="original"></td></tr></tbody></table>

## 3. 스플래시 광고 요청

<mark style="color:red;">`loadRequest`</mark> API를 호출하여 스플래시 광고를 요청합니다.

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

```objectivec
[_sspSplashAd loadRequest];
```

{% endtab %}

{% tab title="Swift" %}

```swift
splashAd.loadRequest()
```

{% endtab %}
{% endtabs %}

## 4. 델리게이트 설정

스플래시 광고에서 발생하는 이벤트에 대한 델리게이트를 제공합니다.

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

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

<table><thead><tr><th width="309">delegate</th><th>설명</th></tr></thead><tbody><tr><td>APSSPSplashAdLoadSuccess</td><td>스플래시 광고 로드 성공</td></tr><tr><td>APSSPSplashAdLoadFail, error</td><td>스플래시 광고 로드 실패. <a href="/ssp-sdk/sdk/ios/ios-3.1.0+/undefined-13.md">에러코드 값</a></td></tr><tr><td>APSSPSplashAdImpression</td><td>스플래시 광고 화면 노출</td></tr></tbody></table>
{% endtab %}

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

<table><thead><tr><th width="307">delegate</th><th>설명</th></tr></thead><tbody><tr><td>apsspSplashAdLoadSuccess</td><td>스플래시 광고 로드 성공</td></tr><tr><td>apsspSplashAdLoadFail(error)</td><td>스플래시 광고 로드 실패. <a href="/ssp-sdk/sdk/ios/ios-3.1.0+/undefined-13.md">에러코드 값</a></td></tr><tr><td>apsspSplashAdImpression</td><td>스플래시 광고 화면 노출</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

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

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

@interface SplashViewController () <APSSPSplashAdDelegate>	
{	
} 
@end	

@implementation SplashViewController 

- (void)viewDidLoad { 
      [super viewDidLoad]; 
      
      _sspSplashAd = [[AdPopcornSSPSplashAd alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) Key:@"YOUR_APP_KEY" placementId:@"YOUR_PLACEMENT_ID" viewController:self];
      _sspSplashAd.delegate = self;
      [_sspSplashAd setFullScreenSplash:YES];
      [self.view addSubView:_sspSplashAd];
      
      [_sspSplashAd loadRequest];
}

#pragma APSSPSplashAdDelegate 
- (void)APSSPSplashAdLoadSuccess:(AdPopcornSSPSplashAd *)splashAd
{
      // 로드 성공, 원하는 시간 만큼 대기 후, 다음 ViewController를 호출한다.
      dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
      	      // 다음 ViewController 호출
      	      NextViewController *next = [[NextViewController alloc] init];
      	      [self presentViewController:next animated:YES completion:nil];
      });
}
- (void)APSSPSplashAdLoadFail:(AdPopcornSSPSplashAd *)splashAd error:(AdPopcornSSPError *)error;
{
      // 로드 실패, 바로 다음 ViewController를 호출한다
      NextViewController *next = [[NextViewController alloc] init];
      [self presentViewController:next animated:YES completion:nil];
}

- (void)APSSPSplashAdImpression:(AdPopcornSSPSplashAd *)splashAd
{
}
@end
```

{% endtab %}

{% tab title="Swift" %}

```swift
class SplashViewController: UIViewController, APSSPSplashAdDelegate
{	
	// SplashAd
    var splashAd: AdPopcornSSPSplashAd!
    override func viewDidLoad() {
        super.viewDidLoad()
	splashAd = AdPopcornSSPSplashAd.init(frame: CGRect(x: 0, y: 0, width: 300, height: 300),
	 key: "YOUR_APP_KEY", placementId: "YOUR_PLACEMENT_ID", viewController: self)     
        splashAd.delegate = self
	splashAd.loadRequest()
    }

	// Splash Delegate
    func apsspSplashAdLoadSuccess(_ splashAd: AdPopcornSSPSplashAd!) {
    }
    func apsspSplashAdLoadFail(_ splashAd: AdPopcornSSPSplashAd!, error: AdPopcornSSPError!) {
    }
    func apsspSplashAdImpression(_ splashAd: AdPopcornSSPSplashAd!) {
    }
}
```

{% endtab %}
{% endtabs %}
