해당 문서는 BuzzAd Nuclues SDK의 광고 지면 타입 중 하나인, Interstitial Type 을 연동하는 문서입니다. Interstitial Type 은 기존의 지면으로 부터 자유롭게, 지면 위에 광고를 노출할 수 있습니다. Bottom sheet, Dialog 등의 방식으로 사용할 수 있습니다.
구현 편의를 위해 제공하는 형태로 커스터마이징이 제한적이기 때문에 조금 더 자유로운 구현을 원하시는 경우, Native Type 을 이용해야 합니다.
다음 과정이 완료 되었는지 확인이 필요합니다.
위의 과정 중 완료되지 않은 항목이 있다면, 이전 단계의 연동을 먼저 완료해야 합니다.
연동하기
1. 기본 설정을 적용하여 구현하기
InterstitialAdHandler 설정하기
[1] InterstitialAdHandler
를 생성한 뒤, 발급받은 Unit Id 를 설정합니다. Dialog 또는 Bottomsheet을 사용할 수 있습니다. (InterstitialAdHandler.Type.Dialog
, InterstitialAdHandler.Type.BottomSheet
)
[2] interstitialAdHandler.show(광고가_노출될_Activity.this)
를 호출하여 광고를 호출합니다.
// 예시에 적힌 "Interstitial_Unit_Id" 를 '버즈빌에서 발급한 Unit Id'로 교체해 주세요. final InterstitialAdHandler interstitialAdHandler = new InterstitialAdHandlerFactory() .create("Interstitial_Unit_Id", InterstitialAdHandler.Type.Dialog); interstitialAdHandler.show(MainActivity.this);
연동하기
2. 추가 설정, 기능을 적용하기
다음 항목에 대한 확인이 필요합니다.
- 연동하기 - [1. 기본 설정을 적용하여 구현하기] 를 통해 기본 값으로 구현을 완료한 광고 지면에서 정상적으로 광고를 확인하고 참여할 수 있는지 확인
디자인 커스터마이즈 - Interstitial Ad Config 설정
Interstitial 의 디자인을 변경할 수 있습니다. 설정된 InterstitialAdConfig
는 interstitialAdHandler.show()
를 호출할 때 넣어서 호출합니다. (아래의 제공 항목을 벗어나는 수정은 어렵습니다.)
[1] 공통 Config
topIcon
: Interstitial 광고 상단에 있는 아이콘 (샘플코드처럼 drawable의 id로 지정하거나 drawable type으로 지정 가능)titleText
: Interstitial 광고 상단에 있는 TexttextColor
: titleText의 색깔layoutBackgroundColor
: Interstitial 광고 전체의 배경 색깔ctaViewBackgroundColorList
: CTA의 배경 색깔ctaRewardDrawable
: CTA에 포함된 기본 아이콘 (샘플코드처럼 drawable의 id로 지정하거나 drawable type으로 지정 가능)ctaParticipatedDrawable
: 광고 참여 완료 후 보여주는 CTA에 포함된 아이콘 (샘플코드처럼 drawable의 id로 지정하거나 drawable type으로 지정 가능)ctaViewTextColor
: CTA의 Text 색깔
[2] Dialog 전용
closeText
: 닫기 버튼의 Text
InterstitialAdConfig interstitialAdConfig = new InterstitialAdConfig.Builder() .topIcon(R.drawable.bz_ic_checked_circle) .titleText("지금 바로 참여하고 포인트 받기") .textColor(android.R.color.white) .layoutBackgroundColor(R.color.colorPrimaryDark) .ctaViewBackgroundColorList(getBackgroundColorStateList()) .ctaRewardDrawable(R.drawable.bz_ic_custom_reward) .ctaParticipatedDrawable(R.drawable.bz_ic_btn_more) .ctaViewTextColor(getTextColorStateList()) .closeText("닫기") .build(); final InterstitialAdHandler interstitialAdHandler = new InterstitialAdHandlerFactory() .create("YOUR_INTERSTITIAL_UNIT_ID", InterstitialAdHandler.Type.Dialog); interstitialAdHandler.show(MainActivity.this, interstitialAdConfig); private ColorStateList getBackgroundColorStateList() { final int[][] states = new int[][]{ new int[]{android.R.attr.state_enabled}, // enabled new int[]{android.R.attr.state_pressed} // pressed }; final int[] colors = new int[]{ ContextCompat.getColor(this, android.R.color.holo_green_light), ContextCompat.getColor(this, android.R.color.holo_green_dark) }; return new ColorStateList(states, colors); } private ColorStateList getTextColorStateList() { int[][] states = new int[][]{ new int[]{android.R.attr.state_enabled}, // enabled new int[]{android.R.attr.state_pressed} // pressed }; int[] colors = new int[]{ Color.WHITE, Color.WHITE }; return new ColorStateList(states, colors); }
여러 개의 광고 로드하기 - Bottom Sheet 전용
InterstitialAdConfig
를 사용하여, Bottom Sheet 에서는 여러개의 광고를 로드할 수 있습니다.
adCount
: 한번에 요청하는 광고의 개수, 최대 5 까지 가능합니다. 기본 값은 5로 설정되어 있습니다.
광고 로드 결과에 대한 리스너 등록
광고가 로드에 실패한 경우에 대해 리스너를 등록할 수 있습니다.
interstitialAdHandler.show(MainActivity.this, interstitialAdConfig, new InterstitialAdHandler.OnInterstitialAdEventListener() { @Override public void onAdLoadFailed(AdError error) { // 로드 실패시. error를 통해 로드 실패 이유를 알 수 있음 } @Override public void onAdLoaded() { // 로드 성공시 } });