배너 광고

안드로이드 가이드 | 배너 광고

배너 광고는 고정 또는 애니메이티드 이미지와 함께 사용자를 웹사이트나 관련 앱 스토어로 이동시키는 하이퍼링크로 구성됩니다. 모든 유형의 앱은 배너 광고를 통해 수익화할 수 있습니다.

간단한 과정을 통해 배너 광고 수익화를 시작해 보십시오.

배너 광고 설정

  1. 배너 광고를 표시하려면 배너 광고 배치 ID가 필요합니다.
  2. 앱을 추가한 후 BANNER AD를 선택하여 배너 광고 유형에 맞는 배치를 생성합니다.
  3. 배너 광고 배치를 생성하면 배치 ID를 사용할 수 있습니다.

앱에 배너 광고 추가

배너 광고 생성

방법 1: XML 레이아웃 리소스 파일에서 배너 광고 추가

XML 레이아웃 리소스 파일에서 배너 광고를 추가하고 일반적인 뷰에서와 마찬가지로 코드에서 배너 광고를 참조할 수 있습니다.

다음 스니펫은 XML에서 배너 광고를 추가하는 방법을 보여줍니다. 최상위 수준 레이아웃 요소에 추가하기 위해 필요한 inmobi ads 네임스페이스를 확인하십시오.

<linearlayout android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="com.inmobi.samples.BannerXMLActivity" xmlns:ads="http://schemas.android.com/apk/lib/com.inmobi.ads" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
    <textview android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/banner_xml_message">
    <com.inmobi.ads.inmobibanner ads:placementid="1431977751489005" ads:refreshinterval="60" android:id="@+id/banner" android:layout_height="50dp" android:layout_width="320dp">
</com.inmobi.ads.inmobibanner></textview></linearlayout>

참고 : 배너 XML 통합의 경우 Android SDK 720 이상을 사용하는 게시자는 다음과 같이 placementId 태그에 'plid-'를 추가해야합니다.

ads : placementId = "plid-1431977751489005"

이제 코드에서 배너 광고를 참조할 수 있습니다.

InMobiBanner bannerAd = (InMobiBanner)findViewById(R.id.banner);

배너 광고 인스턴스를 생성하면 다음 섹션과 같이 광고를 불러오도록 요청할 수 있습니다.

그 전에 메인 액티비티나 배너 광고를 표시하려는 액티비티에서 InMobiSdk.init(Context, String) 메소드를 호출하여 InMobi SDK를 초기화합니다.

방법 2: 코드에서 배너 광고 추가

Android 코드에서 배너 광고를 추가하려면 InMobiBanner의 인스턴스를 생성합니다.

InMobiBanner bannerAd = new InMobiBanner(BannerAdsActivity.this, 1468078426600L);

참고:

  • Application 또는 Service를 사용하여 InMobiBanner를 생성하려고 할 경우 실패할 수 있습니다.
  • InMobiBanner 클래스는 스레드 안정성이 없습니다. 배너 광고 인스턴스는 반드시 UI 스레드에서 생성해야 합니다.
  • 마찬가지로 이 인스턴스 상의 모든 메소드는 해당 UI 스레드에서 호출해야 합니다. 그렇지 않을 경우 예기치 못하게 작동할 수 있으며 InMobi 수익화 기능에 영향을 미칠 수 있습니다.

배너 광고를 생성하고 나면 이를 뷰 계층 구조에 추가할 수 있습니다.

RelativeLayout adContainer = (RelativeLayout) findViewById(R.id.ad_container);
RelativeLayout.LayoutParams bannerLp = new RelativeLayout.LayoutParams(640, 100);
bannerLp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
bannerLp.addRule(RelativeLayout.CENTER_HORIZONTAL);
adContainer.addView(bannerAd, bannerLayoutParams);

참고: 배너 광고의 레이아웃 매개변수 설정 시 배너 광고 뷰 크기를 픽셀 단위로 지정해야 합니다. 또한, WRAP_CONTENT를 배너 광고의 레이아웃 매개변수로 지정하면 프로그래밍 오류가 발생합니다. 이 제한 사항은 XML 레이아웃 리소스 파일이나 코드에서 배너 광고를 생성할 때 모두 적용됩니다.

휴대전화와 태블릿용 앱을 빌드하는 경우 MATCH_PARENT를 배너 광고의 레이아웃 매개변수로 지정할 수 있습니다. InMobi SDK는 배너 광고 크기를 정확하게 연산하여 InMobi 네트워크에서 광고를 불러옵니다.

배너 광고 불러오기

배너 광고를 불러오려면 배너 광고 뷰를 뷰 계층 구조에 추가한 후 광고를 InMobiBanner 인스턴스에서 요청해야 합니다. 뷰를 뷰 계층 구조에 추가하면 InMobi SDK가 배너 광고 뷰 크기를 정확하게 연산하여 네트워크에서 해당 크기에 가장 적합한 광고를 요청합니다.

InMobiBanner를 뷰 계층 구조에 추가하고 나면 광고를 요청하기 위해 생성한 인스턴스의 load() 메소드를 호출할 수 있습니다.

배너 광고의 자동 새로고침 설정

배너 광고는 최초 광고를 요청한 이후 InMobiBanner 인스턴스의 load() 메소드를 호출하여 자동으로 새로고침합니다. XML 레이아웃 리소스 파일이나 이후에 코드에서 배너 광고를 생성할 때 배너 광고의 setRefreshInterval(int) 메소드를 호출하여 자동 새로고침을 설정할 수 있습니다.

아래 샘플은 XML에서 설정하는 방법을 보여줍니다.

<linearlayout android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="com.inmobi.samples.BannerXMLActivity" xmlns:ads="http://schemas.android.com/apk/lib/com.inmobi.ads" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
    <textview android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/banner_xml_message">
    <com.inmobi.ads.inmobibanner ads:placementid="plid-1431977751489005" ads:refreshinterval="60" android:id="@+id/banner" android:layout_height="50dp" android:layout_width="320dp">
</com.inmobi.ads.inmobibanner></textview></linearlayout>

배너 광고 새로고침 애니메이션

배너 광고가 새로고침될 때 나타나는 애니메이션 스타일을 선택할 수 있습니다. 배너 광고 새로고침 시 나타나는 애니메이션 효과를 비활성화하도록 선택할 수도 있습니다. 이를 위해 배너 광고 인스턴스를 생성한 다음 setAnimationType(InMobiBanner.AnimationType) 메소드를 호출합니다.

참고: 기본 애니메이션은 AnimationType.ROTATE_HORIZONTAL_AXIS로 설정되어 있습니다. 설정을 비활성화하려면 AnimationType.ANIMATION_OFF 매개변수의 setAnimationType 메소드를 호출합니다.

배너 광고 수명 주기 이벤트 리스닝

배너 광고 수명 주기의 키 이벤트를 리스닝하려면 BannerAdListener 인터페이스를 구현해야 합니다. 그런 다음 InMobiBanner 인스턴스의 setListener(BannerAdListener) 메소드를 사용하여 리스너를 설정할 수 있습니다. 각 이벤트의 간략한 설명은 다음과 같습니다.

/**
* A listener for receiving notifications during the lifecycle of a banner ad.
*/
public abstract class BannerAdEventListener {
   /**
    * Called to notify that an ad was successfully loaded.
    * @param ad Represents the {@link InMobiBanner} ad which was loaded
    */
   public void onAdLoadSucceeded(InMobiBanner ad) {}
   /**
    * Called to notify that a request to load an ad failed.
    * @param ad Represents the {@link InMobiBanner} ad which failed to load
    * @param status Represents the {@link InMobiAdRequestStatus} status containing error reason
    */
   public void onAdLoadFailed(InMobiBanner ad, InMobiAdRequestStatus status) {}
   /**
    * Called to notify that the user interacted with the ad.
    * @param ad Represents the {@link InMobiBanner} ad on which user clicked
    * @param params Represents the click parameters
    */
   public void onAdClicked(InMobiBanner ad, Map<object, object=""> params) {}
   /**
    * Called to notify that the banner ad was displayed
    * @param ad Represents the {@link InMobiBanner} ad which was displayed
    */
   public void onAdDisplayed(InMobiBanner ad) {}
   /**
    * Called to notify that the User is about to return to the application after closing the ad.
    * @param ad Represents the {@link InMobiBanner} ad which was closed
    */
   public void onAdDismissed(InMobiBanner ad) {}
   /**
    * Called to notify that the user is about to leave the application as a result of interacting with the ad.
    * @param ad Represents the {@link InMobiBanner} ad
    */
   public void onUserLeftApplication(InMobiBanner ad) {}
   /**
    * Called to notify that a reward was unlocked.
    * @param ad Represents the {@link InMobiBanner} ad for which rewards was unlocked
    * @param rewards Represents the rewards unlocked
    */
   public void onRewardsUnlocked(InMobiBanner ad, Map<object, object=""> rewards) {}
  }
	</object,></object,>

배너 광고 연동에 필요한 코드 샘플은 GitHub에서 확인할 수 있습니다.

CreativeID 검색 중

진행되고 있는 모든 광고 품질 검사를 피해나와, 관련성이없고 불쾌한 소재 또는 사용자에게 혼란을주는 광고를 보여줌으로써 앱의 사용자 경험을 손상시키는 불량 광고주가 가끔 있습니다. 이러한 상황을 극복하기 위해 광고 인스턴스의 creativeID를 검색하고 InMobi 담당자에게 암호화 된 creativeID를보고 할 수 있습니다.

mBannerAd.getCreativeId() // mBannerAd는 예제 인스턴스입니다.

통합 테스트

  1. InMobi 포털에서 테스트 모드를 구성합니다.

    Tools - Diagnostics로 이동하여 Test Mode를 Global ON 또는 Selective ON으로 설정합니다.

    광고를 처음으로 연동하려는 경우 Test ModeGlobal ON으로 설정합니다.
    특정 디바이스에 선택적으로 테스트 트래픽을 활성화하려는 경우

    이미 이 광고에 이전 버전의 SDK를 연동한 적이 있으므로 몇 개의 디바이스에 테스팅을 제한해야 하는 경우
    Test ModeSelective ON으로 설정합니다.

    디바이스 섹션에서:

    1. Device ID 상자에 디바이스 ID를 입력합니다.
    2. Device Name 상자에서 이름을 설정합니다.
    3. Add Device를 클릭하여 테스트 디바이스를 추가합니다.

    이미 구성된 디바이스가 있는 경우, 해당 디바이스를 선택하면 테스트 모드가 활성화됩니다.

    참고: 앱을 정식으로 출시하기 전에 반드시 테스트 모드를 비활성화하십시오. 이를 비활성화하지 않으면 앱을 수익화할 수 없습니다.

    이제 테스트를 진행할 수 있습니다.

    디바이스 ID 확인

    디바이스 ID는 Google Play Advertising ID(GPID)입니다. 디바이스 ID를 확인하려면 SDK를 구성하여 디버그 로그를 콘솔에 출력합니다. 이를 위해 다음 라인을 배너 광고를 연동하려는 액티비티에 추가합니다.

    InMobiSdk.setLogLevel(LogLevel.DEBUG);
    
    


    디바이스 ID가 DDMS 콘솔의 디버그 로그에 출력됩니다.

  2. Diagnostics 탭에서 광고 및 광고 요청에 대한 피드백을 확인할 수도 있으며, 이는 특히 연동 과정에서 유용하게 활용할 수 있습니다.

유용한 디버그 정보

1단계에서 언급한 대로 디버그 로그를 활성화했다면 SDK가 초기화 및 광고 로드 수명 주기와 유용한 관련 정보를 제공하는 주요 로그를 DDMS 콘솔에 출력하게 됩니다.

다음 표는 이러한 로그를 설명합니다.

SDK 초기화

시나리오 로그 수준 로그
Publisher passed null or empty account id (퍼블리셔가 null 또는 빈 계정 ID를 전달함) 오류 Account id cannot be null or empty. Please provide a valid Account id.
Publisher passed a valid account id (퍼블리셔가 올바른 계정 ID를 전달함) 디버그 InMobi SDK initialized with account id: <account id="" />
Publisher passed an invalid account Id (퍼블리셔가 잘못된 계정 ID를 전달함) 오류 Invalid account id passed to init. Please provide a valid account id.
Publisher didn't grant the mandatory permissions (퍼블리셔가 필수 권한을 허용하지 않음) 디버그 Please grant the mandatory permissions : INTERNET & ACCESS_NETWORK_STATE, SDK could not be initialized.
Permissions granted to the SDK (SDK에 권한 허용됨) 디버그 Permissions granted to the SDK are : <list granted="" of="" permissions="" />
Newer version of SDK is available (SDK 버전이 업데이트됨) 디버그 A newer version (ver. 6.0.0) of the InMobi SDK is available! You are currently on an older version (ver. 5.3.1). Download the latest InMobi SDK from http://www.inmobi.com/products/sdk/#downloads

일반적인 광고 수명 주기 메시지

시나리오 로그 수준 로그
Ad requested when no network available (네트워크를 사용할 수 없을 때 광고 요청됨) 오류 로그 수준 Network not reachable currently. Please try again.
Ad requested when ad state is loading or available (광고 상태를 불러오는 중이거나 사용할 수 있을 때 광고 요청됨) 오류 로그 수준 An ad load is already in progress. Please wait for the load to complete before requesting for another ad (Placement id : <placement id="" />).
Ad requested when ad is viewed by user (사용자가 광고를 시청 중일 때 광고 요청됨) 오류 로그 수준 An ad is currently being viewed by the user. Please wait for the user to close the ad before requesting for another ad (Placement id : <placement id="" />).
Publisher device Id (퍼블리셔 디바이스 ID) 디버그 로그 수준 Publisher device id is
Requested ad being returned from cache (캐시로부터 반환 중인 광고 요청됨)   Returning ad from cache for the Placement Id - <placement id="" />
Requested ad being fetched from network (네트워크에서 가져오고 있는 광고 요청됨)   Ad will be fetched from network for the Placement Id - <placement id="" />

배너 광고 연동 관련 메시지

시나리오 로그 수준 로그
Publisher created a banner without initializing the SDK (퍼블리셔가 SDK를 초기화하지 않고 배너 광고를 생성함) 오류 Please initialize the SDK before creating a Banner ad
Publisher created a banner with an invalid/null placement id (퍼블리셔가 잘못된/null 배치 ID로 배너 광고를 생성함) 오류  
Publisher called load on a banner from IB/xml with improper placement id (퍼블리셔가 배치 ID가 부적절한 IB/xml 배너 광고에 로드를 호출함) 오류 Placement id value supplied in XML layout is not valid. Banner creation failed.
For Banner created in XML, no placement id provided (XML로 생성된 배너 광고에 배치 ID가 제공되지 않음) 오류 Placement id value is not supplied in XML layout. Banner creation failed.
Publisher called load on a banner (퍼블리셔가 배너 광고에 로드를 호출함) 디버그 Fetching a Banner ad for placement id: <placement id="" />
Successfully fetched ad (광고를 가져옴) 디버그 Banner ad successfully fetched for placement id: <placement id="" />
Failed to fetch the ad (광고를 가져오지 못함) 디버그 Failed to fetch Banner ad for placement id: <placement id="" /> with error: <status code="" message="" />
Started loading the banner in a webview (배너 광고를 웹뷰로 불러오기 시작함) 디버그 Started loading Banner ad markup in the webview for placement id: <placement id="" />
Banner successfully loaded in the webview (배너 광고를 웹뷰로 불러옴) 디버그 Successfully loaded Banner ad markup in the webview for placement id: <placement id="" />
Failed to load banner in the webview (배너 광고를 웹뷰로 불러오지 못함) 디버그 NA <placement id="" />
Banner refresh is initiated (배너 광고 새로고침이 초기화됨) 디버그 Initiating Banner refresh for placement id: <placement id="" />
Invalid placement id (올바르지 않은 배치 ID) 오류 Placement id value supplied in XML layout is not valid. Banner creation failed.
invalid refresh interval (올바르지 않은 새로고침 주기) 디버그 Refresh interval value supplied in XML layout is not valid. Falling back to default value.
Null Context (Null 컨텍스트) 오류 Context supplied as null, the ad unit can't be created.
Layout params not set (레이아웃 매개변수가 설정되지 않음) 오류 The layout params of the banner must be set before calling load
Height or width set to WRAP_CONTENT (높이 또는 너비가 WRAP_CONTENT로 설정됨) 오류 The height or width of a Banner ad can't be WRAP_CONTENT
Height or width not set (높이 또는 너비 설정 안 됨) 오류 The height or width of the banner cannot be determined
Null listener (Null 리스너) 오류 Please pass a non-null listener to the banner.

SDK에 의해 출력된 로그를 비롯하여 Diagnostics 탭에서 광고 및 광고 요청에 대한 피드백을 확인할 수도 있으며, 이는 특히 연동 과정에서 유용하게 활용할 수 있습니다.

이 페이지가 도움이 되었나요?

이 페이지에서

마지막 업데이트 날짜: 17 Sep, 2020