# 연동 기본 설정

1\. 미디에이션 설정

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

* 애드팝콘 미디에이션 <mark style="color:red;">(cocoaPod, SPM)</mark> <mark style="color:$info;">지원 가능</mark>

{% content-ref url="/pages/vQLrbkT7sJaljMrWTUXI" %}
[AP 미디에이션(Unity iOS)](/ssp-sdk/undefined-1/ap/ap-unity-ios.md)
{% endcontent-ref %}

* Max 미디에이션(Beta) <mark style="color:red;">(CocoaPod)</mark> <mark style="color:$info;">지원 가능</mark> : 사용하고자 할 경우 사업팀에 문의 하세요&#x20;

{% content-ref url="/pages/DGLMxrxr1x9dXhf5cUgK" %}
[MAX 미디에이션(Beta, Unity iOS)](/ssp-sdk/undefined-1/max-beta/max-beta-unity-ios.md)
{% endcontent-ref %}

## 2. 코드 연동

#### 1) IDFA 설정

IDFA(Identifier for Advertisers)는 Apple이 iOS 기기에 부여하는 광고 식별자입니다. \
사용자 맞춤형 광고를 제공하고 광고 성과를 측정하기 위해 사용됩니다.

AdSupport Framework를 Dependencies에 추가합니다.

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

***

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

iOS 14부터 앱이 IDFA에 접근하려면 사용자에게 명시적으로 <mark style="color:red;">**추적 허용을 요청**</mark>해야 합니다. \
App Tracking Transparency(ATT) framework를 Dependencies에 추가하고, `Info.plist`에 `NSUserTrackingUsageDescription` 키를 추가합니다.

```xml
<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>
```

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

{% tabs %}
{% tab title="Swift" %}

```swift
import AppTrackingTransparency
import AdSupport

func requestIDFA() {
    ATTrackingManager.requestTrackingAuthorization { status in
        // 승인 여부 결과를 받은 후, 광고 로드를 시작합니다.
    }
}
```

{% endtab %}

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

```objc
#import <AppTrackingTransparency/AppTrackingTransparency.h>
#import <AdSupport/AdSupport.h>

- (void)requestIDFA {
    [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
        // 승인 여부 결과를 받은 후, 광고 로드를 시작합니다.
    }];
}
```

{% endtab %}
{% endtabs %}

***

### 3) 델리게이트 설정

각 광고 타입별 델리게이트가 정상적으로 동작하기 위해서는 아래의 내용이 필수로 설정되어 있어야 합니다.

* <mark style="color:red;">GameObject의 이름을 제대로 넘겨주는지 확인</mark>
  * APSSPSDKPluginIOS.SetCallbackHandler("APSSPSDKSample");
* <mark style="color:red;">GameObject에 이용하려는 서비스 plugin파일을 추가 했는지 확인</mark>
  * SSP 관련 delegate를 이용하려면 Plugins/IOS 폴더 밑에 있는 APSSPSDKPluginIOS 파일을 GameObject에 추가했는지 확인 필요

위 2가지 사항을 적용한 예시는 아래 스크린샷의 하이라이트 처리 된 부분을 참고 부탁 드립니다.

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

***

## 1. 초기화

### LogType

<table><thead><tr><th width="155.096435546875" align="center">값</th><th>설명</th></tr></thead><tbody><tr><td align="center">0</td><td>None (릴리즈용)</td></tr><tr><td align="center">1</td><td>All (디버깅용)</td></tr></tbody></table>

### MediationProvider

<table><thead><tr><th width="161.1510009765625" align="center">값</th><th>설명</th></tr></thead><tbody><tr><td align="center">0</td><td>AdPopcornSSP (기본)</td></tr><tr><td align="center">1</td><td>AppLovin MAX</td></tr><tr><td align="center">2</td><td>AdMob</td></tr></tbody></table>

### Gender

<table><thead><tr><th width="162.5963134765625" align="center">값</th><th>설명</th></tr></thead><tbody><tr><td align="center">1</td><td>Female</td></tr><tr><td align="center">2</td><td>Male</td></tr><tr><td align="center">3</td><td>Unknown</td></tr></tbody></table>

```csharp
void Awake()
{
    APSSPSDKPluginIOS.SetCallbackHandler("APSSPSDKSample");  // GameObject 이름과 일치 필수

    // Initialize(appKey, logType, adInspectorEnabled, mediationProvider)
    APSSPSDKPluginIOS.Initialize("YOUR_APP_KEY", 1, true, 0);  // logType=All, adInspector=ON, provider=AdPopcornSSP

    APSSPSDKPluginIOS.SetUserId("TEST_USN");
    APSSPSDKPluginIOS.TagForChildDirectedTreatment(false);
    // APSSPSDKPluginIOS.SetUIDIdentifier(0, "test@adpopcorn.com");  // UID 2.0 (선택)
    // APSSPSDKPluginIOS.SetAge(25);          // 선택
    // APSSPSDKPluginIOS.SetGender(2);        // 선택 (1=Female, 2=Male, 3=Unknown)
}
```

{% hint style="warning" %}
`SetCallbackHandler`의 파라미터는 `APSSPSDKPluginIOS` 스크립트가 붙어있는 **GameObject 이름**과 반드시 일치해야 합니다.\
릴리즈 빌드에서는 `logType=0`, `adInspectorEnabled=false`로 설정하세요.
{% endhint %}


---

# Agent Instructions: 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:

```
GET https://adpopcornssp.gitbook.io/ssp-sdk/sdk/unity/unity-ios/undefined.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
