Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

Adding GDPR European Ad Consent Message with React Native Google Mobile Ads (ADMOB) using Expo

Tiempo de lectura: 2 minutos

Today we are going to learn how we can add the mandatory ad consent message to comply with GDPR.

The first thing we need to do is to have our message set up: https://devcodelight.com/mensaje-consentimiento-conforme-rgpd-para-admob/

NOTE: I am using version 12.2.0 of react-native-google-mobile-ads at least (https://github.com/invertase/react-native-google-mobile-ads)

Once configured, let’s go to android/app/proguard-rules.pro and add:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
-keep class com.google.android.gms.internal.consent_sdk.** { *; }
-keep class com.google.android.gms.internal.consent_sdk.** { *; }
-keep class com.google.android.gms.internal.consent_sdk.** { *; }

Now we need to go to our app.json of Expo to add:

In my case I have to add it to the rest of the attributes I use:

Now we need to activate delay_app_measurement_init when starting the ads so we go to the configuration of «react-native-google-mobile-ads» inside app.json:

Now we have to rebuild the APP:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
npx expo prebuild
npx expo prebuild
npx expo prebuild

And now let’s create the component that will allow us to generate the alert:

UserConsent.js

And to use it we will do the following:

<

p Lets go to our home screen and add this component:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<AdsUserConsent/>
<AdsUserConsent/>
<AdsUserConsent/>

To make it work correctly, we must rebuild a development build, we can use this command locally:

or remotely with Expo:

And now the following message should appear:

0

Leave a Comment