AdFit

SDK 설치

  • v3.17.2 호환 지원합니다.

api 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10'
api 'com.kakao.adfit:ads-base:3.17.2'
  • build.gradle 프로젝트 레벨에 저장소 설정을 추가합니다.

allprojects {
    repositories {
        maven { url 'https://devrepo.kakao.com/nexus/content/groups/public/' }
    }
}

배너 추가 설정

AdFit 배너 광고를 사용하는 지면에서는 아래의 추가 코드 연동이 필요합니다. AdPopcornSSPBannerAd 인스턴스의 onResume, onPause를 activity life cycle에 맞추어 호출해 줍니다.

MainActivity.java
@Override
protected void onResume() {
    super.onResume();
    if(bannerAdView != null)
        bannerAdView.onResume();
}

@Override
protected void onPause() {
    super.onPause();
    if(bannerAdView != null)
        bannerAdView.onPause();
}

네이티브 광고 추가 설정

다른 타입의 광고와 다르게 네이티브 광고에서 미디에이션 사용하고자 할 경우에는 레이아웃에 대한 추가 설정이 필요합니다.

AdFit 네이티브의 경우 일반 네이티브와 BizBoard 네이티브를 지원하므로, 매체에서 사용하고자 하는 방식에 맞게 연동을 진행해 주세요.

BizBoard

AdPopcornSSPNativeAd layout 내에 AdFitBizBoardAdTemplateLayout 영역을 추가해 주세요

  • native_ad_mediation_layout.xml 샘플

<?xml version="1.0" encoding="utf-8"?>
<com.igaworks.ssp.part.nativead.AdPopcornSSPNativeAd
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/adpopcorn_native_ad"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    ...
    <!-- AdFit BizBoard -->
    <com.kakao.adfit.ads.na.AdFitBizBoardAdTemplateLayout
        android:id="@+id/adFitNativeAdView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
...
</com.igaworks.ssp.part.nativead.AdPopcornSSPNativeAd>

AdFit 비즈보드 스타일의 경우 UI 템플릿을 직접 설정할 필요가 없기에 native_ad_mediation_layout 파일 안에 영역만 지정해 주면 됩니다.

그리고 지정한 영역을 아래와 같이 setAdFitViewBinder를 통해 BizBoard 영역이라고 설정합니다.

AdFitViewBinder adFitViewBinder = new AdFitViewBinder.Builder(R.id.adFitNativeAdView)
                .bizBoardAd(true)
                .build();
adPopcornSSPNativeAd.setAdFitViewBinder(adFitViewBinder);

직접 연동

AdPopcornSSPNativeAd layout 내에 GfpNativeSimpleAdView 영역을 추가해 주세요

  • native_ad_mediation_layout.xml 샘플

<?xml version="1.0" encoding="utf-8"?>
<com.igaworks.ssp.part.nativead.AdPopcornSSPNativeAd
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/adpopcorn_native_ad"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    ...
    <!-- NAM SimpleAd -->
    <com.naver.gfpsdk.GfpNativeSimpleAdView
        android:id="@+id/gfp_native_simple_ad"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </com.naver.gfpsdk.GfpNativeSimpleAdView>
...
</com.igaworks.ssp.part.nativead.AdPopcornSSPNativeAd>

  • adfit_native_ad_unit_layout.xml 샘플

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="3dp"
        android:gravity="center_vertical"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/adfit_profile_icon_view"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:contentDescription="AD Profile Icon"
            tools:src="@mipmap/ic_launcher" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="7dp"
            android:layout_marginRight="7dp"
            android:gravity="center_vertical"
            android:orientation="vertical">

            <TextView
                android:id="@+id/adfit_title_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textStyle="bold"
                tools:text="AD Title" />

            <TextView
                android:id="@+id/adfit_profile_name_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                tools:text="AD Profile Name" />
        </LinearLayout>
    </LinearLayout>

    <com.kakao.adfit.ads.na.AdFitMediaView
        android:id="@+id/adfit_media_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="3dp" />

    <TextView
        android:id="@+id/adfit_body_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="3dp"
        tools:text="AD Description" />

    <Button
        android:id="@+id/adfit_call_to_action_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:text="AD Call To Action Button" />
</LinearLayout>

xml에서 생성한 ui component를 sdk에서 제공하는 setAdFitViewBinder API를 이용해 아래와 같이 설정해 줍니다.

AdFitViewBinder adFitViewBinder = new AdFitViewBinder.Builder(R.id.adFitNativeAdView, R.layout.adfit_native_ad_unit_layout)
        .titleViewId(R.id.adfit_title_view)
        .bodyViewId(R.id.adfit_body_view)
        .profileIconViewId(R.id.adfit_profile_icon_view)
        .profileNameViewId(R.id.adfit_profile_name_view)
        .callToActionButtonId(R.id.adfit_call_to_action_button)
        .mediaViewId(R.id.adfit_media_view)
				.testMode(false)
        .build();
adPopcornSSPNativeAd.setAdFitViewBinder(adFitViewBinder);

테스트 광고 송출을 원할 경우, testModetrue 값을 전달하여 준다.

Last updated

Was this helpful?