Android user messaging platform isConsentFormAvailable returns false

1.6k views Asked by At

I followed this guide https://developers.google.com/admob/ump/android/quick-start and my code looks like this:

    private fun checkForConsent() {
/*
        val debugSettings = ConsentDebugSettings.Builder(this)
            .setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA)
            .addTestDeviceHashedId("69887E2CBBE5346EC3B54A3FD207AB41")
            .build()
        val params = ConsentRequestParameters.Builder()
            .setConsentDebugSettings(debugSettings)
            .build()
        */


        Log.d("adstuff", "check Consent")
        val params = ConsentRequestParameters.Builder().build()
        // Set tag for under age of consent. Here false means users are not under age
        //Log.d("adstuff", params.isTagForUnderAgeOfConsent.toString())

        consentInformation = UserMessagingPlatform.getConsentInformation(this)

        //consentInformation.reset();
        consentInformation.requestConsentInfoUpdate(
            this,
            params,
            object : ConsentInformation.OnConsentInfoUpdateSuccessListener {
                override fun onConsentInfoUpdateSuccess() {
                    // The consent information state was updated.
                    // You are now ready to check if a form is available.
                    Log.d("adstuff", "Is consentform available")
                    Log.d("adstuff", consentInformation.isConsentFormAvailable.toString())

                    if (consentInformation.isConsentFormAvailable) {
                        Log.d("adstuff", "Consentform is available")

                        loadForm()
                    }
                }
            },
            object : ConsentInformation.OnConsentInfoUpdateFailureListener {
                override fun onConsentInfoUpdateFailure(formError: FormError) {
                    // Handle the error.
                    Log.d("adstuff", "content info update failure")
                    Log.d("adstuff", formError.toString())

                }
            })
    }

However, consentInformation.isConsentFormAvailable returns false. I made an AdMob account and a Funding Choices account where I created and published a message of type Consent TCF. I have also added the ca-app-pub ID to the Android Manifest.

Thanks

Edit: If I set the location to the EEA using the debug settings, like in the commented code, the consent info update fails.

2

There are 2 answers

1
Jose Luis Larraz On

In your phone go to Settings > Privacy > Advanced > Ads and toggle off "Opt out of Ads Personalization"

0
Ernesto On

For other people having the same issue, I was testing this from an emulator, and the documentation from Google states that it's not required to add the device ID in this case, however this was not working because of that. In Logcat I can see this:

I/UserMessagingPlatform(21870): Use new ConsentDebugSettings.Builder().addTestDeviceHashedId("AAA01CDEB36EFED43AEFFD2EB9D778C2") to set this as a debug device.

Then after adding the device ID for the emulator as described, it started working as expected.