> 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/unity/unity-ios/unity-plugin-2.x.x/undefined.md).

# 연동 기본 설정

1\. 미디에이션 설정

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

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

{% content-ref url="/pages/vQLrbkT7sJaljMrWTUXI" %}
[Unity Plugin 2.x.x](/ssp-sdk/undefined-1/ap/ap-unity-ios/unity-plugin-2.x.x.md)
{% endcontent-ref %}

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

{% content-ref url="/pages/DGLMxrxr1x9dXhf5cUgK" %}
[Unity Plugin 2.x.x](/ssp-sdk/undefined-1/max-beta/max-beta-unity-ios/unity-plugin-2.x.x.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>All (디버깅용)</td></tr><tr><td align="center">1</td><td>network</td></tr><tr><td align="center">2</td><td>info</td></tr><tr><td align="center">3</td><td>error</td></tr><tr><td align="center">4</td><td>none (릴리즈용)</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()
    {
        // Bridge 오브젝트 생성 (Scene 당 1회)
        if (FindObjectOfType<APSSPSDKBridge>() == null)
        {
            var go = new GameObject("APSSPSDKBridge");
            go.AddComponent<APSSPSDKBridge>();
        }

        APSSPSDKPluginIOS.SetCallbackHandler("APSSPSDKBridge");

        // Initialize(appKey, logType, adInspectorEnabled, mediationProvider)
        // logType: 0=All, 1=network, 2=info, 0=error, 1=none
        // mediationProvider: 0=AdPopcornSSP, 1=AppLovinMAX
        APSSPSDKPluginIOS.Initialize("YOUR_APP_KEY", 0, false, 0);

        APSSPSDKPluginIOS.SetUserId("USER_ID");
        APSSPSDKPluginIOS.TagForChildDirectedTreatment(false);
        // APSSPSDKPluginIOS.SetGdprConsentAvailable(true);             // GDPR (선택)
        // APSSPSDKPluginIOS.SetUIDIdentifier(0, "email@test.com");     // UID2.0 (선택, 0=email, 1=phone)
        // APSSPSDKPluginIOS.SetAge(25);                                 // 선택
        // APSSPSDKPluginIOS.SetGender(2);                               // 선택 (1=Female, 2=Male, 3=Unknown)
    }
```

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