How can i detect AdMob GDPR user consent?

Not favoritedFavorited Favorited 0 favourites
  • 3 posts
From the Asset Store
AdMob Plus PRO
$12.99 USD
[ Support C3 Build service ] Native Ad, App Open Ad, Banner Ad, Interstitial Ad, Rewarded Interstitial Ad, Rewarded Ad.
  • Hi everyone!

    I'm using the MobileAdvert plugin to integrate AdMob ads into my game. However, I've encountered an issue: if a user does not consent to GDPR, ads are not displayed. This appears to be a policy enforced by Google.

    Is there a way to determine whether the user has accepted or declined GDPR consent? This would allow me to take appropriate action, such as displaying a prompt or restricting certain app content.

    Thank you.

    Tagged:

  • Bump.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Writing for anyone who might stumble across this in the future.

    Consent for AdMob GDPR message is provided as a string of "1" and "0" called IABTCF string. When you tap "Accept", this string becomes "1111111111", when you tap "Reject", it becomes "0000000000", and when you individually specify the privacy options through the menu, each character becomes 1 if you tick the corresponding option, and 0 if you don't.

    The problem is that, since we are using Google UMP SDK, we really can't access that string from Costruct (even by using javascript), so we need a Cordova plugin that can pass that information to Construct via an addon. Fortunately EMI INDO made an addon called "AdMob pro" which provides a way to get the IABTCF string using one of his Cordova plugins.

    I'll share the code I used as a reference to anyone who has the same problem:

    It's not the best thing in the world, but I had some problems with identifying when consent changed, so I opted for this solution instead, which gets the job done.

    Keep in mind that you'll have to build your game manually for this to work. To do this you'll need Android Studio, Gradle, JDK and possibly other stuff. Once you're all set up, export your project as a Cordova project, extract the zip, locate the extracted folder and run cmd in that folder. Then run

    cordova platform add android

    And when that is completed, store a copy of your keystore somewhere on your computer, and in cmd type

    cordova build android --release -- --keystore=PATH_TO_KEYSTORE\keystore.jks --storePassword=PASSWORD --alias=KEY_ALIAS --password=PASSWORD --packageType=bundle

    After everything is completed, a message should pop up in your terminal indicating the location of the generated signed .aab file.

    Hope that helps :)

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)