User Messaging Platform for Android misses the user consent status
Asked Answered
E

1

6

I'm trying to obtain the consent from the users using User Messaging Platform. Followed this guide:

https://developers.google.com/admob/ump/android/quick-start

When I run the code in the guide it shows the consent correctly. If I press "Consent" the consent status changes to ConsentInformation.ConsentStatus.OBTAINED which is ok.

But when I kill and re-open the app again, after calling requestConsentInfoUpdate, it seems to reset the consent status to ConsentInformation.ConsentStatus.REQUIRED and prompts again for consent.

How can I avoid that and only prompt once for consent?

Enthusiast answered 31/5, 2022 at 13:31 Comment(3)
Please try admob setup on console as mentioned in this link? support.google.com/admob/answer/7666519?hl=enGaidano
Everything in the console seems to be setupEnthusiast
Same problem here. This issue just started after I tried some changes in the Admob Console Message and privacy settings. Now the users of my apps are constantly seeing the consent formShocking
E
0

First make sure you are using the latest version of UMP SDK inside your dependencies and don't rely on the version embedded with play-services-ads, that version could be outdated.

dependencies {
   implementation("com.google.android.gms:play-services-ads:22.6.0")
   implementation("com.google.android.ump:user-messaging-platform:2.2.0")
}

Second, in my case Android DataStore was causing preferences reset. The same preferences file is used to store consent from UMP SDK, coincidently they had the same name. It seems that DataStore tries to migrate all preferences when it finds the preferences file, and then deletes it, which causes UMP SDK to lose stored consent info.

companion object {

    private const val PREFS_FILE_NAME = "user_prefs"
    private val Context.dataStore by preferencesDataStore(
        name = PREFS_FILE_NAME,
        produceMigrations = {
            listOf(SharedPreferencesMigration(it, it.packageName + "_preferences"))
        })
}

UMP SDK uses my.package.name_preferences.xml file by default (can't change it) to store consent info. My old preferences also were stored in the same file, and when I switched to DataStore I had to make a migration from that file.

To resolve the issue, I simply removed the migration since it is not that important for me.

Evaleen answered 24/2 at 7:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.