# 기본 설정

## 1. SDK 릴리즈 노트

{% content-ref url="undefined-10" %}
[undefined-10](https://adpopcornssp.gitbook.io/ssp-sdk/sdk/android/undefined-10)
{% endcontent-ref %}

## 2. SDK 설치

애드팝콘 SDK의 지원 버전은 아래와 같습니다.

```
minSdkVersion 15
targetSdkVersion 35
```

### 2.1 Gradle 설치

Gradle을 이용하여 SDK를 설정합니다.

#### build.gradle 설정

{% tabs %}
{% tab title="프로젝트 수준 build.gradle 설정" %}

```less
allprojects {
    repositories {
        mavenCentral()
    }
}
```

{% endtab %}

{% tab title="앱 수준 build.gradle 설정" %}

```java
dependencies {
    implementation 'com.igaworks.ssp:IgawAdPopcornSSP:3.10.1'
}
```

{% endtab %}
{% endtabs %}

### 2.2 수동 설치

Gradle 설정을 이용하지 않고 수동으로 SDK 다운로드 하고자 할 경우 아래 다운로드 링크를 통해 최신 안드로이드 SDK 패키지를 다운로드 합니다.

* [애드팝콘 SSP SDK 다운로드](https://github.com/IGAWorksDev/AdPopcornSDK/raw/refs/heads/master/AdPopcornSSP/01-android-sdk/AdPopcornSSP_v3.10.0a.zip)

다운로드 받은 .zip 파일을 압축해제하여 <mark style="color:blue;">`AdPopcornSSP~*.aar`</mark> 파일을 안드로이드 스튜디오 프로젝트로 복사한 후 gradle 을 업데이트합니다.

<div align="left"><figure><img src="https://content.gitbook.com/content/qmkw7pJLtjFGD5fwChbN/blobs/pgukCjV1OMefKdgvpHM3/image.png" alt=""><figcaption></figcaption></figure></div>

SDK 복사 후 아래와 같이 <mark style="color:red;">`build.gradle`</mark> 에 dependiencies 를 추가하고 업데이트 합니다.

```
dependencies { 
    compile(name: 'AdPopcornSSP_3.10.1a', ext: 'aar')
    repositories { flatDir { dirs 'libs' } }
}
```

## 3. 매니페스트 설정

애드팝콘 SSP를 이용하기 위한 내용을 <mark style="color:red;">`AndroidManifest.xml`</mark> 파일에 추가합니다.

### 1) 앱 키 추가

[애드팝콘 SSP 콘솔페이지](https://www.console.adpopcorn.com/)에서 애드팝콘 앱 등록 후 발급받은 앱 키를 \<application> \</application> 태그 안에 추가합니다.

{% code title="XML" %}

```xml
<application>
... 
<meta-data android:name="adpopcorn_ssp_app_key" android:value="이곳에_앱키를_입력하세요"/> 
...
</application>
```

{% endcode %}

### 2) 퍼미션 추가

\<manifest>\</manifest> 태그 안에 필수 퍼미션을 추가합니다.

{% code title="XML" %}

```xml
<manifest>
... 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
...
</manifest>
```

{% endcode %}

## 4. 미디에이션 설정

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

* 애드팝콘 미디에이션

{% content-ref url="../../undefined-1/ap/ap-android" %}
[ap-android](https://adpopcornssp.gitbook.io/ssp-sdk/undefined-1/ap/ap-android)
{% endcontent-ref %}

* Max 미디에이션(Beta) : 사용하고자 할 경우 사업팀에 문의 하세요

{% content-ref url="../../undefined-1/max-beta/max-beta-android" %}
[max-beta-android](https://adpopcornssp.gitbook.io/ssp-sdk/undefined-1/max-beta/max-beta-android)
{% endcontent-ref %}

## 5. 필수 코드 연동

애드팝콘 SSP는 배너, 리워드 비디오, 전면, 네이티브 등 다양한 형태의 광고를 제공하고 있습니다.&#x20;

{% hint style="warning" %}
각 광고 형식별 연동을 진행하기에 앞서서 기본 API를 이용하여 초기화 작업을 진행하여야 합니다.
{% endhint %}

### 1) SSP SDK 초기화

<mark style="color:red;">`init API`</mark>를 어플리케이션 실행 후 최초로 로드되는 activity 혹은 application class에서 호출하여줍니다.

init 중복 호출 시, 그 사이에 세팅된 광고가 초기화 됨으로 중복 호출을 방지하고자 할 때에는 isInitialized API를 통해 초기화 작업이 완료된 상태인지 체크하시기 바랍니다.

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

<pre class="language-java"><code class="lang-java">if(AdPopcornSSP.isInitialized(getApplicationContext())){
<strong>    // Already SSP SDK initialized
</strong>}
else{
    AdPopcornSSP.init(getApplicationContext(), new SdkInitListener() {
        @Override
        public void onInitializationFinished() {
             // init 작업이 완료 된 뒤, 광고 로드 작업을 진행해 주시기 바랍니다.         
        }
    });
}
</code></pre>

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
AdPopcornSSP.init(applicationContext, object : SdkInitListener{
    override fun onInitializationFinished() {
	  // init 작업이 완료 된 뒤, 광고 로드 작업을 진행해 주시기 바랍니다.
    }
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
&#x20;인앱 비딩 사용 시, 반드시 초기화 완료 후 광고 요청을 진행해 주세요.
{% endhint %}

### 2) 리소스 해제

<mark style="color:red;">`destroy API`</mark>를 이용하여 어플리케이션이 종료될 때 메모리에 할당된 SSP 관련 리소스(View,Memory)를 해제합니다. 앱이 종료될 때 호출되는 activity의 <mark style="color:red;">`onDestroy()`</mark>에서 호출합니다.

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

```java
@Override
protected void onDestroy() {	
    // TODO Auto-generated method stub	
    super.onDestroy();	
    
    AdPopcornSSP.destroy();
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
override fun onDestroy() {	
	// TODO Auto-generated method stub	
	super.onDestroy()
	AdPopcornSSP.destroy()
}
```

{% endtab %}
{% endtabs %}

### 3) 유저 타게팅 옵션 (Optional)

유저 타게팅 정보를 세팅하실 경우, 타게팅이 가능한 미디에이션에 자동으로 타게팅 정보가 세팅됩니다.

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

```java
AdPopcornSSPUserProperties userProperties = new AdPopcornSSPUserProperties.Builder()
		.gender(0)
		.yob(1984)
		.language("KR")
		.country("KO")
		.build();
AdPopcornSSP.setUserProperties(userProperties);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val userProperties = AdPopcornSSPUserProperties.Builder()
		.gender(0)
		.yob(1984)
		.language("KR")
		.country("KO")
		.build()
AdPopcornSSP.setUserProperties(userProperties)
```

{% endtab %}
{% endtabs %}

<table data-full-width="false"><thead><tr><th width="145">key</th><th width="135">설명</th><th width="131">type</th><th>예시</th></tr></thead><tbody><tr><td>gender</td><td>성별</td><td>int</td><td>0: 남성, 1: 여성, 2: 알 수 없음</td></tr><tr><td>yob</td><td>출생년도</td><td>int</td><td>1990</td></tr><tr><td>language</td><td>언어</td><td>string</td><td>"KR"</td></tr><tr><td>country</td><td>국가</td><td>string</td><td>"KO"</td></tr></tbody></table>

### 4) UID 2.0 설정 (Optional)

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

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

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

* Email
* PhoneNumber
  {% endhint %}

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

```java
AdPopcornSSP.setUIDIdentifier(this, AdPopcornSSP.UIDIdentifierType.EMAIL, "test_uid@adpopcorn.com");
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
AdPopcornSSP.setUIDIdentifier(this@MainActivity, AdPopcornSSP.UIDIdentifierType.EMAIL, "test_uid@adpopcorn.com")
```

{% endtab %}
{% endtabs %}

### 5) GDPR 설정

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

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

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

```java
AdPopcornSSP.gdprConsentAvailable(false);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
AdPopcornSSP.gdprConsentAvailable(false)
```

{% endtab %}
{% endtabs %}

### 6) COPPA 설정

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

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

```java
AdPopcornSSP.tagForChildDirectedTreatment(context, true);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
AdPopcornSSP.tagForChildDirectedTreatment(this@MainActivity, 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>
