사용자는 '이 광고 끄기' 기능을 통해 광고를 닫거나 광고가 표시되지 않게 하여 관심이 없는 광고임을 알릴 수 있습니다. 기본 버전은 다음과 같습니다(맞춤 버전 아님).
UnifiedNativeAd
를 이용하면 사용자가 네이티브 광고를 끌 수 있도록 자체 UI를
구현할 수 있습니다. 구현 방법은 다음과 같습니다.
맞춤 '이 광고 끄기' 요청
먼저, 광고 요청을 할 때 NativeAdOptions.Builder
클래스의
setRequestCustomMuteThisAd
를 사용하여 맞춤 '이 광고 끄기' 기능을
사용 설정하세요.
자바
AdLoader adLoader = new AdLoader.Builder(context, "ad unit ID") .forUnifiedNativeAd(new UnifiedNativeAd.OnUnifiedNativeAdLoadedListener() { @Override public void onUnifiedNativeAdLoaded(UnifiedNativeAd unifiedNativeAd) { // Show the ad. } }) .withAdListener(new AdListener() { @Override public void onAdFailedToLoad(int errorCode) { // Handle the failure by logging, altering the UI, and so on. } }) .withNativeAdOptions(new NativeAdOptions.Builder() .setRequestCustomMuteThisAd(true) .build()) .build(); adLoader.loadAd(new AdRequest.Builder().build());
Kotlin
val adLoader = AdLoader.Builder(context, "ad unit ID") .forUnifiedNativeAd { ad -> // Show the ad } .withAdListener(object : AdListener() { override fun onAdFailedToLoad(errorCode: Int) { // Handle the failure by logging, altering the UI, and so on. } }) .withNativeAdOptions(NativeAdOptions.Builder() .setRequestCustomMuteThisAd(true) .build()) .build() adLoader.loadAd(AdRequest.Builder().build())
맞춤 '이 광고 끄기'를 사용할 수 있는지 확인
네이티브 광고가 로드되면
UnifiedNativeAd
객체의
isCustomMuteThisAdEnabled()
메서드에서 반환된 값을 확인합니다. 반환된 값이 true이면
맞춤 광고 끄기 버튼/동작을 추가하고
UnifiedNativeAd
객체의.
getMuteThisAdReasons()
메서드에서 사용할 수 있는
MuteThisAdReason
으로 맞춤 광고 끄기 인터페이스를 구성합니다.
자바
// In OnUnifiedNativeAdLoadedListener @Override public void onUnifiedNativeAdLoaded(UnifiedNativeAd unifiedNativeAd) { // Show the ad. ... this.nativeAdView.setNativeAd(unifiedNativeAd); if (nativeAd.isCustomMuteThisAdEnabled()) { enableCustomMuteWithReasons(nativeAd.getMuteThisAdReasons()); } else { hideCustomMute(); } } ... private void enableCustomMuteWithReasons(List<MuteThisAdReason> reasons) { //TODO: This method should show your custom mute button and provide the list // of reasons to the interface that are to be displayed when the user mutes // the ad. } private void hideCustomMute() { //TODO: Remove / hide the custom mute button from your user interface. }
Kotlin
// When constructing the ad loader. builder.forUnifiedNativeAd { unifiedNativeAd -> // Show the ad. ... this.nativeAdView.nativeAd = nativeAd if (nativeAd.isCustomMuteThisAdEnabled) { enableCustomMuteWithReasons(nativeAd.muteThisAdReasons); } else { hideCustomMute(); } } ... private fun enableCustomMuteWithReasons(reasons: List<MuteThisAdReason>) { //TODO: This method should show your custom mute button and provide the list // of reasons to the interface that are to be displayed when the user mutes // the ad. } private fun hideCustomMute() { //TODO: Remove / hide the custom mute button from your user interface. }
맞춤 광고 끄기 인터페이스의 구현은 게시자가 정합니다. 광고에 작은 닫기 버튼을 넣거나, 사용자가 광고 끄기를 선택할 수 있는 다른 인터페이스를 제공할 수도 있습니다.
'이 광고 끄기'가 나타난 이유 표시
맞춤 '이 광고 끄기'를 사용할 수 있으면 UnifiedNativeAd
의 muteThisAdReasons
속성에서 일련의 MuteThisAdReason
객체를 사용할 수 있습니다.
MuteThisAdReason
에는 getDescription()
메서드가 있으며 여기에는 표시 가능한 문자열이
제공됩니다.
Google에서는 이러한 이유를 사용자에게 표시하고 광고 끄기 옵션을 제공하도록 권장하고 있습니다. 사용자가 이유 중 하나를 클릭하면 선택한 이유와 함께 광고 끄기를 보고해야 합니다.
사용자가 닫기 버튼을 클릭할 때 이러한 이유를 표시하지 않고 바로 광고 끄기를 보고할 수도 있습니다.
광고 끄기
광고를 끄려면 아래의 두 작업을 해야 합니다.
UnifiedNativeAd
의muteThisAd
메서드를 사용하여 광고 끄기 이유를 네이티브 광고에 보고합니다.해당 UI에서 원하는 방식으로 직접 광고를 끄거나 숨깁니다.
자바
private void muteAdDialogDidSelectReason(MuteThisAdReason reason) { // Report the mute action and reason to the ad. nativeAd.muteThisAd(reason); muteAd(); } private void muteAd { //TODO: Mute / hide the ad in your preferred manner. }
Kotlin
private fun muteAdDialogDidSelectReason(reason: MuteThisAdReason) { // Report the mute action and reason to the ad. nativeAd.muteThisAd(reason) muteAd() } private fun muteAd() { //TODO: Mute / hide the ad in your preferred manner. }
광고 끄기 확인 받기(선택사항)
광고 끄기 보고가 완료되었다는 알림을 받으려면 UnifiedNativeAd
의
setMuteThisAdListener
메서드를 사용하여
설정된 MuteThisAdListener
를 구현하세요. onAdMuted()
메서드는 광고가 제대로 꺼진 경우에만
호출됩니다.
자바
nativeAd.setMuteThisAdListener(new MuteThisAdListener() { @Override public void onAdMuted() { Toast.makeText(getActivity(), "Ad muted", Toast.LENGTH_SHORT).show(); } });
Kotlin
nativeAd.setMuteThisAdListener { Toast.makeText(activity, "Ad muted", Toast.LENGTH_SHORT).show() }