Consent API (UMP) on Android Question

83 views
Skip to first unread message

Nikolas Spiridakis

unread,
Jan 21, 2025, 2:09:30 PM1/21/25
to Google Mobile Ads SDK Developers
Hello.
Here you mention that before I do MobileAds.initialize(), I should handle everything related to consent/UMP first. On the UMP docs you mention that I can call canRequestAds() either after loadAndShowConsentFormIfRequired() or right after requestConsentInfoUpdate(). On the latter, the response can be cached from the previous app session since we haven't even checked if we even need to show a consent form. But in order make use of canRequestAds() I need to do MobileAds.initialize(). So would it be correct to do MobileAds.initialize() and start serving ads right after requestConsentInfoUpdate() in case the cached canRequestAds() is true and then do loadAndShowConsentFormIfRequired() (which might show a consent form again)? And then after loadAndShowConsentFormIfRequired() I wouldn't need to initialize again, right? I assume the ads will refresh automatically in case there is a new consent form?

The reason I try to do all this is to make the ads loading faster since we have a cached value for canShowAds. And in the rare case there is an new consent form we show that and refresh the ads.

Thank you

Nikolas Spiridakis

unread,
Jan 21, 2025, 2:26:39 PM1/21/25
to Google Mobile Ads SDK Developers
This is what I was thinking. Will this cause any problem?


consentInformation = UserMessagingPlatform.getConsentInformation(this);
consentInformation.requestConsentInfoUpdate(
        this,
        params,
        () -> {
            canShowAds = consentInformation.canRequestAds();
            if (canShowAds) {
                initAds();
            }


            UserMessagingPlatform.loadAndShowConsentFormIfRequired(
                    this,
                    formError -> {
                        boolean canShowAdsOld = canShowAds;

                        canShowAds = consentInformation.canRequestAds();

                        if (!canShowAdsOld) {
                            initAds();
                        }

                    }
            );
        },
        formError -> showAdsError()
);

Mobile Ads SDK Forum Advisor

unread,
Jan 21, 2025, 5:40:43 PM1/21/25
to 1nikol...@gmail.com, google-adm...@googlegroups.com
Hi,

As of now I would suggest to follow the streps to load ad which mentioned in this doc.
Because using other ways of checking consent status, such as the cache on your app or a previously saved consent string, can lead to a TCF 3.3 error if consent is expired.

Meanwhile I will raise this concern (optimized way to ad load after consent provided) to the wider team and will get back to you with an update.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02vGxmV:ref" (ADR-00285370)

Thanks,
 
Google Logo Mobile Ads SDK Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5


 


Nikolas Spiridakis

unread,
Jan 21, 2025, 6:09:53 PM1/21/25
to Google Mobile Ads SDK Developers
With "cache" I was referring to this statement from the docs:
"The UMP SDK might have obtained consent in the previous app session."

Which basically means it has the consent "cached" or rather saved in the app's data and knows if it would need to show a consent message or not. This statement was referring to when you could call canRequestAds().

Thanks
Reply all
Reply to author
Forward
0 new messages