Provide proper example to implement UMP consent to show only banner ads of Admob in single screen app

722 views
Skip to first unread message

Super User

unread,
Jan 20, 2022, 12:33:08 AM1/20/22
to Google Mobile Ads SDK Developers
Hi,

Can you please provide proper example of implement UMP consent in single activity app ?

For example, for cash calculator have only single screen with one admob banner.

please answer below question
1) which point we need to take consent?  and 
2) when to initialize mobile ads sdk?  then
3) need to pass any flag during ads request?
4) what if user click on do not consent button ?

Mobile Ads SDK Forum Advisor

unread,
Jan 20, 2022, 5:22:36 AM1/20/22
to uade...@gmail.com, google-adm...@googlegroups.com

Hi Super User,

Thank you for reaching out to us.

Let me answer your questions as best as I can.

please answer below question

1) which point we need to take consent? and 

  • If you want to implement UMP, you can follow this documentation for Android or iOS. It is recommended that you request an update of the consent information at every app launch. This will determine whether or not your user needs to provide consent.

2) when to initialize mobile ads sdk? then

  • For Android, before loading ads, have your app initialize the Google Mobile Ads SDK by calling MobileAds.initialize() which initializes the SDK and calls back a completion listener once initialization is complete (or after a 30-second timeout). Then, for iOS, before loading ads, call the startWithCompletionHandler: method on the GADMobileAds.sharedInstance, which initializes the SDK and calls back a completion handler once initialization is complete (or after a 30-second timeout).

3) need to pass any flag during ads request?

  • Can you confirm what flag you are referring to?

4) what if user click on do not consent button ?

  • If users do not consent, the ads that will be displayed are non-personalized ads.

Regards,

Google Logo
Princess Pamela Pineda
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2VNiKC:ref

Super User

unread,
Jan 20, 2022, 5:53:38 AM1/20/22
to Google Mobile Ads SDK Developers
More clarification given below to explain my case.

2) when to initialize mobile ads sdk , after consent screen or in application class? 
 For example, on app launch we implemented UMP, then we need to wait for user consent every time to initialize mobile sdk ?  or we can call mobile sdk in background during that UMP process.

3)  need to pass any flag during ads request?

For example, How to build each AdRequest
if user provide consent or not

//1. Create an ad request.
val adRequest = AdRequest.Builder().build()

OR

//2. Create an ad request with flag for do not consent
Bundle extras = new Bundle();
extras
.putString("npa", "1");
AdRequest request = new AdRequest.Builder()
   
.addNetworkExtrasBundle(AdMobAdapter.class, extras)
   
.build();

4) So, we need to create different AdRequest based on user consent ? or sdk auto manage it to display personalized or non personalized ads ?
 This question refers to after implementing UMP for consent.

As all documents are separate and no proper connection between them , we face lots of difficulties to implement it properly.

Mobile Ads SDK Forum Advisor

unread,
Jan 20, 2022, 10:23:28 AM1/20/22
to uade...@gmail.com, google-adm...@googlegroups.com

Hi Super User,

Thank you for your response. Let me provide additional context with regard to your questions.

2) when to initialize mobile ads sdk , after consent screen or in application class? 

 For example, on app launch we implemented UMP, then we need to wait for user consent every time to initialize mobile sdk ? or we can call mobile sdk in background during that UMP process.

  • You can initialize the Mobile Ads SDK, then, you can add the consent form implementation under it. Just make sure that both are inside onCreate activity. Then if you want to show the ads, for example banner ads, you can add the loadAd request inside onConsentInfoUpdateSuccess. In addition to that, you can try to test it using this implementation.

3) need to pass any flag during ads request?

For example, How to build each AdRequest

if user provide consent or not

//1. Create an ad request.

val adRequest = AdRequest.Builder().build()

OR

//2. Create an ad request with flag for do not consent

Bundle extras = new Bundle();

extras.putString("npa", "1");

AdRequest request = new AdRequest.Builder()

   .addNetworkExtrasBundle(AdMobAdapter.class, extras)

   .build();

  • As per checking the code snippet, I think it is the same request. The only difference is that if the user does not consent, you just add a "addNetworkExtrasBundle". But, as far as I know, it is still the same AdRequest class that can call the loadAd process.
  • For example for banner, if you want to call the ads, you need to used this sample code snippet
    • AdRequest adRequest = new AdRequest.Builder().build(); mAdView.loadAd(adRequest);.
  • While, if it's not consented, you used
    • Bundle extras = new Bundle(); extras.putString("npa", "1"); AdRequest request = new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class, extras).build();mAdView.loadAd(request);

4) So, we need to create different AdRequest based on user consent ? or sdk auto manage it to display personalized or non personalized ads ?

 This question refers to after implementing UMP for consent.

  • As per checking in our documentation, the default behavior of the Google Mobile Ads SDK is to serve personalized ads. If a user has consented to receive only non-personalized ads, you can configure an AdRequest object to specify that only non-personalized ads should be requested. 

Super User

unread,
Jan 22, 2022, 2:36:21 AM1/22/22
to Google Mobile Ads SDK Developers
I have implemented UMP as below

1) initialize sdk inside onCreate()  at application class level
    MobileAds.initialize(this) {}

​2) add the consent form implementation under it.

Now, load banner ads in my activity with this step

Google Admob SDK auto detect consent value for each adrequest ? Like personalized/managed options/not personalized etc ?

or do i need to find out value of consent and pass it to each  AdRequest manually ? If yes, how to find out it ?

Mobile Ads SDK Forum Advisor

unread,
Jan 24, 2022, 2:30:57 AM1/24/22
to uade...@gmail.com, google-adm...@googlegroups.com
Hello,

I work along with Princess. Allow me to assist you in this.

With regard to your concern, the SDK will automatically handle the request with the consent status selected by the user. Just take note that you need to request the after onConsentInfoUpdateSuccess method has been called.

Regards,
Google Logo
Teejay Wennie Pimentel
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2VNiKC:ref

Super User

unread,
Jan 24, 2022, 4:28:13 AM1/24/22
to Google Mobile Ads SDK Developers
Hi Teejay,

Thanks for sharing more information about that. I understand now.

Super User

unread,
Jan 24, 2022, 5:24:32 AM1/24/22
to Google Mobile Ads SDK Developers
One final question, because consent required on every app launch.

Can we put UMP code for consent seeking in splash screen ? or it is invalid to take consent in splash screen ?

Mobile Ads SDK Forum Advisor

unread,
Jan 24, 2022, 10:40:32 AM1/24/22
to uade...@gmail.com, google-adm...@googlegroups.com

Hi Super User,

Thank you for your response.

With regard to your question, as long as you show the consent information before requesting any ads it should be fine. But, I would suggest to follow the guide on our developer guide to request it at every app launch, usually on Oncreate activity to avoid any further errors.

Regards,

Google Logo
Princess Pamela Pineda
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2VNiKC:ref
Reply all
Reply to author
Forward
0 new messages