Ahsan Ali
Ahsan Ali

Reputation: 361

Admob nativ ads not showing ADCHOICE Icon?

I am working on an app and placed some native ads. All things are working fine but code is not show Adchoice icon i tried with different side value but still not working and is it mandatory to use adchoice icon for native ads or i can just leave it .................

//Admob Ads
implementation 'com.google.android.gms:play-services-ads:20.2.0'


   //Nativ ads Code
   object NativeAds {


fun intializeNativeAds(context: Context, unitId: String, template: TemplateView): AdLoader{


    val videoOptions = VideoOptions.Builder()
        .setStartMuted(false)
        .build()

    val adOptions = NativeAdOptions.Builder()
        .setVideoOptions(videoOptions)
        .setRequestCustomMuteThisAd(true)
        .setAdChoicesPlacement(ADCHOICES_TOP_RIGHT)
        .build()

    val adLoaded = AdLoader.Builder(context, unitId).forNativeAd {
       val nativeAds  =  it

     val   mediaContent = nativeAds.mediaContent

        if(mediaContent!=null  && mediaContent.hasVideoContent()){

            println("Vide is availble ")

            mediaContent.videoController.videoLifecycleCallbacks = object : VideoController.VideoLifecycleCallbacks(){

                override fun onVideoStart() {
                    super.onVideoStart()

                println("Started ")
                }

                override fun onVideoPlay() {
                    super.onVideoPlay()
                println("Play ")
                }

                override fun onVideoPause() {
                    super.onVideoPause()
                }

                override fun onVideoEnd() {
                    super.onVideoEnd()
                }
            }


        }


       template.setNativeAd(nativeAds)


    }.withNativeAdOptions(adOptions).withAdListener(object : AdListener(){
        override fun onAdFailedToLoad(loadError: LoadAdError) {
            println("Failure to Load "+ loadError.message )
        }
    })
    return adLoaded.build()
}

}

Upvotes: 1

Views: 1165

Answers (2)

DoctorWho
DoctorWho

Reputation: 1116

If your implementation is correct the adChoices will be shown in case you have a real advertisement and not during the tests. You will simply have to publish the app, use the correct and non-test codes and you will see that it will appear

Upvotes: 3

Akash Chaudhary
Akash Chaudhary

Reputation: 711

Ad_choices_icon is automatically added by Admob, you don't have to add it. You can only change its position.

Upvotes: 3

Related Questions