Vidar Vestnes
Vidar Vestnes

Reputation: 42974

How to pass user consent to AdMob (GDPR)

I'm using AdMob to serve ads to users in EU. The documentation states that I can pass the user consent status by the following line of code:

AdRequest request = new AdRequest.Builder() .AddExtra("npa", "1") .Build();

The problem is that this line does not compile. There is no such function as AddExtra on the AdRequst object. I do use the latest AdMob library available.

  implementation 'com.google.android.gms:play-services-ads:15.0.1'
  implementation 'com.google.firebase:firebase-ads:15.0.1'

So, how do I actually pass this "npa" value to AdMob.

Anyone?

Upvotes: 4

Views: 2791

Answers (1)

Dhaval Solanki
Dhaval Solanki

Reputation: 4705

you can add npa using addNetworkExtrasBundle method which like bellow

Bundle bundleExtra = new Bundle();
        bundleExtra.putString("npa", "1");

        AdRequest addRequest = new AdRequest.Builder()
                .addNetworkExtrasBundle(AdMobAdapter.class, bundleExtra)
                .build();

And also please check bellow official link
https://developers.google.com/admob/android/eu-consent#forward_consent_to_the_google_mobile_ads_sdk

Upvotes: 4

Related Questions