how display Google-rendered consent form with react-native-firebase/admob

Viewed 378

I am trying to integrate google ads to my react native app, so I followed everything from the official docs https://rnfirebase.io/ and I managed to display google ads. but when it comes to European User Consent I cant display the Google-rendered consent because the result of the method AdsConsentInfo isRequestLocationInEeaOrUnknown is always false even I whitelist my device an set a debug location :

async componentDidMount(){

     AdsConsent.addTestDevices(['MY_DEVICE_ID'])

     const consentInfo = await AdsConsent.requestInfoUpdate(['pub-XXXXXX']);
     await AdsConsent.setDebugGeography(AdsConsentDebugGeography.EEA);
   
    if (
    consentInfo.isRequestLocationInEeaOrUnknown &&
     consentInfo.status === AdsConsentStatus.UNKNOWN
    ) {
     const formResult = await AdsConsent.showForm({
       privacyPolicy: 'https://invertase.io/privacy-policy',
       withPersonalizedAds: false,
     withNonPersonalizedAds: true,
      withAdFree: false,
    });
 
   
   }

}

2 Answers

try and use, use react-native-ads-consent together with firebase ads consent for instance try setting the debug geography with react-native-ads-consent and check location and display the consent form using react-native-firebase ads consent

Place the code block inside a try catch and use a vpn and set the location to any European Country then you will get isRequestLocationInEeaOrUnknown: true

async componentDidMount () {
  try {
        const consentInfo = await AdsConsent.requestInfoUpdate([
          'pub-xxxxxx',
        ]);
        await AdsConsent.setDebugGeography(AdsConsentDebugGeography.EEA);
      if (
        consentInfo.isRequestLocationInEeaOrUnknown &&
        consentInfo.status === AdsConsentStatus.UNKNOWN
      ) {
        const formResult = await AdsConsent.showForm({
          privacyPolicy: 'https://www.google.com/privacy-policy/',
          withPersonalizedAds: false,
          withNonPersonalizedAds: true,
          withAdFree: false,
        });

        console.log('formResult', formResult);
      }
    } catch (e) {
      console.log('error', e.message);
    }
}

Related