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

# 기본 설정

## 1. SDK 설치 방법

### 1) CocoaPods&#x20;

{% content-ref url="/pages/sSuYYIx7BCNW7Y7X3Kv2" %}
[CocoaPod 설치](/ssp-sdk/sdk/ios/ios-2.x.x/undefined/cocoapod.md)
{% endcontent-ref %}

### 2) SPM(Swift Package Manager) &#x20;

{% content-ref url="/pages/Bfi9zJfHz2OL6gVo18ED" %}
[SPM 설치](/ssp-sdk/sdk/ios/ios-3.1.0+/undefined/spm.md)
{% endcontent-ref %}

### 3) 수동 &#x20;

{% content-ref url="/pages/WDynbWvD2e4tZlfI6px9" %}
[수동 설치](/ssp-sdk/sdk/ios/ios-2.x.x/undefined/undefined.md)
{% endcontent-ref %}

## 2. 미디에이션 설정

애드팝콘에서는 2가지 형태의 미디에이션을 지원합니다. 하나의 방식을 선택하여 연동 진행해 주세요.

* 애드팝콘 미디에이션

{% content-ref url="/pages/IP2R7MXm9WlEBdvJxfnZ" %}
[iOS 2.x.x (구버전)](/ssp-sdk/undefined-1/ap/ap-ios/ios-2.x.x.md)
{% endcontent-ref %}

* Max 미디에이션(Beta) : 사용하고자 할 경우 사업팀(<pm@adpopcorn.com>)에 문의 하세요

{% content-ref url="/pages/inI4X4hiPeJ8WPpyw8Zg" %}
[iOS 2.x.x (구버전)](/ssp-sdk/undefined-1/max-beta/max-beta-ios/ios-2.x.x.md)
{% endcontent-ref %}

## 3. 코드 연동

{% hint style="danger" %}
애드팝콘 SSP framework의 경우 Objective-C를 기반으로 생성되었기에 swift에서 사용하고자 할 경우 아래의 환경을 세팅해 주어야 합니다.
{% endhint %}

{% tabs %}
{% tab title="swift 사용 시 환경 설정" %}

1. **Bridge Header 추가**

```swift
//
// AdPopcorn-Bridging-Header.h
// AdPopcornSSPSwiftSample
//
// Created by mick on 2018. 9. 13..
// Copyright (c) 2021년 AdPopcorn. All rights reserved.
//
#ifndef SwiftAdPopcornSSP_ObjectiveC_Header_h
#define SwiftAdPopcornSSP_ObjectiveC_Header_h

#import <AdPopcornSSP/AdPopcornSSP.h>
#import <AdPopcornSSP/AdPopcornSSPAdSize.h>
#import <AdPopcornSSP/AdPopcornSSPBannerView.h>
#import <AdPopcornSSP/AdPopcornSSPError.h>
#import <AdPopcornSSP/AdPopcornSSPInterstitialAd.h>
#import <AdPopcornSSP/AdPopcornSSPInterstitialVideoAd.h>
#import <AdPopcornSSP/AdPopcornSSPNativeAd.h>
#import <AdPopcornSSP/AdPopcornSSPRewardVideoAd.h>
#import <AdPopcornSSP/AdPopcornSSPSplashAd.h>
#import <AdPopcornSSP/AdPopcornSSPWKScriptMessageHandler.h>
#import <AdPopcornSSP/AdPopcornSSPModalAd.h>
#import <AdPopcornSSP/AdPopcornSSPContentsAd.h>
#import <AdPopcornSSP/AdPopcornSSPPopContentsAd.h>
#import <AdPopcornSSP/AdPopcornSSPVideoMixAd.h>
#import <AdPopcornSSP/AdPopcornSSPRewardAdPlus.h>
#import <AdPopcornSSP/APSSPRewardAdPlusStatusModel.h>
#endif
```

Objective-C로 구성된 header 파일을 swift에서 사용할 수 있게 bridge header 파일 생성 후 사용하고자 하는 header 파일 import 해줍니다.

<figure><img src="/files/5jKzELdTMvWGNZnndIoH" alt=""><figcaption></figcaption></figure>

2. **Build Setting 내 Header 파일 추가**

위에서 생성한 bridge Header 파일을 build setting 에 선언해 줍니다.<br>

<figure><img src="/files/ZGv3YIWQ4T6koDmEaslo" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

### 1) IDFA 설정

AdSupport Framework를 Dependencies에 추가합니다.

{% hint style="info" %}
AdSupport Framework가 추가되지 않으면 애드팝콘 SSP 서비스가 정상 동작 하지 않습니다.
{% endhint %}

### 2) iOS 14 IDFA 사용 동의 설정

{% hint style="danger" %} <mark style="color:red;">iOS 14 버전의 사용자에게는 AdSupport Framework 추가 이외에 아래의 연동을 통해 수집 동의를 받아야 합니다.</mark>
{% endhint %}

1. App Tracking Transparency framework를 Dependencies에 추가합니다.
2. 앱 추적 투명성 승인 요청

IDFA에 액세스하기 위한 앱 추적 투명성 승인 요청을 표시하려면 <mark style="color:red;">`Info.plist`</mark>을 업데이트하여 사용을 설명하는 맞춤 메시지와 함께 <mark style="color:red;">`NSUserTrackingUsageDescription`</mark> 키를 추가합니다. 다음은 설명 텍스트의 예입니다.

<figure><img src="/files/BSCUShxq0jrt9aiOKyju" alt=""><figcaption><p>This identifier will be used to deliver personalized ads to you.</p></figcaption></figure>

위와 같이 설정 후, 다음과 같이 코드 상에서 <mark style="color:red;">`requestTrackingAuthorizationWithCompletionHandler:`</mark>를 호출하여 승인 요청을 합니다. 승인 요청할 경우 아래와 같은 동의 팝업이 노출되게 됩니다.

<figure><img src="/files/ABfIRe82QLCsLofMTn5Q" alt=""><figcaption></figcaption></figure>

승인 여부에 대한 결과 값을 받은 후, 광고 로드를 시작하여야 애드팝콘 SDK에서 IDFA를 사용할 수 있습니다. 이에 해당 API는 광고 요청 전에 반드시 마무리 되어야 합니다.

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

```swift
#import <AppTrackingTransparency/AppTrackingTransparency.h>
#import <AdSupport/AdSupport.h>
...
- (void)requestIDFA {
  [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
    // Tracking authorization completed. Start loading ads here.    
  }];
}
```

{% endtab %}

{% tab title="Swift" %}

```swift
import AppTrackingTransparency
import AdSupport
...
func requestIDFA() {
  ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
    // Tracking authorization completed. Start loading ads here.   
  })
}
```

{% endtab %}
{% endtabs %}

### 3) 로그 수준 설정

SDK에서 노출하는 로그의 수준을 설정할 수 있습니다.

<mark style="color:red;">`setLogLevel`</mark> API를 이용하여 설정하며 수준을 결정하는 값은 AdPopcornSSP.h 에 정의된 enum을 사용하며 각 수준은 다음과 같습니다.

<table><thead><tr><th width="276">값</th><th>설명</th></tr></thead><tbody><tr><td>AdPopcornSSPLogInfo</td><td>info 수준의 가장 기본적인 로그를 노출 합니다.</td></tr><tr><td>AdPopcornSSPLogDebug</td><td>info 를 포함한 Debug 수준의 로그를 노출 합니다.</td></tr><tr><td>AdPopcornSSPLogTrace</td><td>모든 로그를 노출합니다.</td></tr></tbody></table>

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

```swift
[AdPopcornSSP setLogLevel:AdPopcornSSPLogTrace];
```

{% endtab %}

{% tab title="Swift" %}

<pre class="language-swift"><code class="lang-swift"><strong>AdPopcornSSP.setLogLevel(AdPopcornSSPLogTrace);
</strong></code></pre>

{% endtab %}
{% endtabs %}

### 4) SSP SDK 초기화

{% hint style="warning" %}
InAppBidding을 사용하는 매체의 경우 아래 init API를 사용해, 초기화를 진행해 주어야 합니다. 그렇지 않을 경우, InAppBidding을 사용하는 placement 지면에 대한 업데이트가 이루어지지 않아, inAppBidding이 동작하지 않습니다.
{% endhint %}

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

```swift
#import <AdPopcornSSP/AdPopcornSSP.h>

@interface AppDelegate() <APSSPSDKInitializeDelegate>
@end

@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
	[AdPopcornSSP sharedInstance].initializeDelegate = self;
	[AdPopcornSSP initializeSDK:@"YOUR_APP_KEY"];
}

#pragma mark - APSSPSDKInitializeDelegate
- (void)AdPopcornSSPSDKDidInitialize
{
	// 초기화가 완료 된 이후, 광고 요청 작업을 수행해 주시기 바랍니다.
}
@end
```

{% endtab %}

{% tab title="Swift" %}

```swift
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, APSSPSDKInitializeDelegate
{
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        AdPopcornSSP.sharedInstance().initializeDelegate = self;
        AdPopcornSSP.initializeSDK("YOUR_APP_KEY");
        return true
    }

    // Initialize Delegate
    func adPopcornSSPSDKDidInitialize() {

    }
}
```

{% endtab %}
{% endtabs %}

### 5) UID 2.0 설정

쿠팡 DSP로 부터 높은 단가의 광고를 제공 받기 위해서는 UID 2.0 설정을 진행하여야 합니다.

[애드팝콘 SSP 콘솔 페이지](https://www.console.adpopcorn.com/) 내 개인정보보호약정서에 동의한 매체의 경우 아래 API를 통해 UID 설정을 진행해 주어야 합니다.

{% hint style="info" %}
UIDIdentifier Type은 아래 2가지를 지원합니다.

* 0: Email
* 1: PhoneNumber
  {% endhint %}

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

```swift
[AdPopcornSSP setUIDIdentifier:0 identifier:@"test_uid@adpopcorn.com"];
```

{% endtab %}

{% tab title="Swift" %}

```swift
AdPopcornSSP.setUIDIdentifier(0, identifier:"test_uid@adpopcorn.com")
```

{% endtab %}
{% endtabs %}

### 6) GDPR 설정

EU의 GDPR (General Data protection Regulation) 법안에 대응하기 위해 아래 API를 추가 합니다.

GDPR 동의 여부 세팅을 위해 아래의 API가 추가 되었습니다. 기본 값은 <mark style="color:red;">**YES(true)**</mark> 이고 GDPR 동의가 필요한 유저에 한해 아래 API를 호출하시기 바랍니다.

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

```objectivec
[AdPopcornSSP gdprConsentAvailable:NO];
```

{% endtab %}

{% tab title="Swift" %}

```swift
AdPopcornSSP.gdprConsentAvailable(false)
```

{% endtab %}
{% endtabs %}

### 7) COPPA 설정

COPPA 대응을위해 아래의 API가 추가 되었습니다. 기본 값은 <mark style="color:red;">NO(false)</mark> 이고 COPPA에 따라 콘텐츠를 아동 대상으로 지정하려면 아래 API를 이용하여 YES(true) 로 설정해 주세요

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

```objectivec
[AdPopcornSSP tagForChildDirectedTreatment:NO];
```

{% endtab %}

{% tab title="Swift" %}

```swift
AdPopcornSSP.tag(forChildDirectedTreatment: true)
```

{% endtab %}
{% endtabs %}

* google families policy : <https://play.google.com/about/families/#!?zippy_activeEl=designed-for-families#designed-for-families>
* coppa : <https://www.ftc.gov/tips-advice/business-center/privacy-and-security/children's-privacy>
