invertase / react-native-google-mobile-ads

React Native Google Mobile Ads enables you to monetize your app with AdMob.
https://docs.page/invertase/react-native-google-mobile-ads
Other
668 stars 135 forks source link

[🐛] No ads shown when I use "Manage options" on consent screen #401

Closed rKatex closed 1 year ago

rKatex commented 1 year ago

What happened?

I'm currently in the process of adding the admob consent screen to my app. The problem I'm facing is, that as soon as I choose "Manage option", even if i click on every consent checkbox, I won't see any ads. The ad inspector just tells me "No Fill".

If I click on "Consent" at the beginning or "Manage Options" and then "Accept all" I will see ads.

Platforms

Android, but have not tested behavior on iOS

React Native Info

System:
    OS: Linux 6.2 Ubuntu 23.04 23.04 (Lunar Lobster)
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
    Memory: 9.55 GB / 31.04 GB
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 18.3.0 - ~/.nvm/versions/node/v18.3.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.3.0/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v18.3.0/bin/npm
    Watchman: 20221225.010033.0 - /usr/local/bin/watchman
  SDKs:
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
  Languages:
    Java: 11.0.12 - /home/*****/.sdkman/candidates/java/11.0.12-open/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.71.7 => 0.71.7 
  npmGlobalPackages:
    *react-native*: Not Found

Are your using Typescript?

package.json

{
  "name": "***",
  "version": "0.0.1",
  "private": true,
  "scripts": {
      ....
  },
  "dependencies": {
    "@aws-crypto/sha256-js": "4.0.0",
    "@aws-sdk/client-cognito-identity": "3.325.0",
    "@aws-sdk/client-s3": "3.325.0",
    "@aws-sdk/credential-provider-cognito-identity": "3.325.0",
    "@aws-sdk/signature-v4": "3.310.0",
    "@bam.tech/react-native-image-resizer": "3.0.5",
    "@invertase/react-native-apple-authentication": "2.2.2",
    "@lingui/react": "3.17.2",
    "@notifee/react-native": "7.7.1",
    "@openspacelabs/react-native-zoomable-view": "^2.1.1",
    "@react-native-async-storage/async-storage": "1.18.1",
    "@react-native-community/netinfo": "9.3.9",
    "@react-native-community/slider": "4.4.2",
    "@react-native-firebase/app": "17.4.3",
    "@react-native-firebase/messaging": "17.4.3",
    "@react-navigation/bottom-tabs": "6.5.7",
    "@react-navigation/elements": "1.3.17",
    "@react-navigation/material-bottom-tabs": "6.2.15",
    "@react-navigation/native": "6.1.6",
    "@react-navigation/native-stack": "6.9.12",
    "@shopify/flash-list": "1.4.3",
    "@stomp/stompjs": "7.0.0",
    "@tanstack/query-async-storage-persister": "^4.29.5",
    "@tanstack/react-query": "4.29.5",
    "@tanstack/react-query-persist-client": "^4.29.5",
    "@trivago/prettier-plugin-sort-imports": "3.4.0",
    "axios": "1.4.0",
    "chroma-js": "2.4.2",
    "date-fns": "2.30.0",
    "deepmerge": "4.3.1",
    "express": "4.18.2",
    "fast-text-encoding": "1.0.6",
    "jwt-decode": "^3.1.2",
    "make-plural": "7.2.0",
    "object-hash": "3.0.0",
    "qs": "6.11.1",
    "react": "18.2.0",
    "react-native": "0.71.7",
    "react-native-app-auth": "6.4.3",
    "react-native-bootsplash": "^4.7.1",
    "react-native-clean-project": "4.0.1",
    "react-native-config": "1.5.0",
    "react-native-device-info": "10.6.0",
    "react-native-fast-image": "8.6.3",
    "react-native-fs": "2.20.0",
    "react-native-geolocation-service": "5.3.1",
    "react-native-gesture-handler": "2.9.0",
    "react-native-get-random-values": "1.8.0",
    "react-native-google-mobile-ads": "11.1.0",
    "react-native-image-crop-picker": "0.39.0",
    "react-native-image-progress": "^1.2.0",
    "react-native-keychain": "8.1.1",
    "react-native-linear-gradient": "2.6.2",
    "react-native-localize": "2.2.6",
    "react-native-maps": "1.7.1",
    "react-native-paper": "5.7.2",
    "react-native-rate": "^1.2.12",
    "react-native-safe-area-context": "4.5.2",
    "react-native-screens": "3.20.0",
    "react-native-toast-message": "2.1.6",
    "react-native-url-polyfill": "1.3.0",
    "react-native-vector-icons": "9.2.0",
    "semver": "7.3.8",
    "text-encoding": "0.7.0",
    "use-debounce": "9.0.4",
    "usehooks-ts": "^2.9.1",
    "uuid": "9.0.0"
  },
  "devDependencies": {
    "@babel/core": "7.21.8",
    "@babel/runtime": "7.21.5",
    "@lingui/cli": "3.17.2",
    "@lingui/core": "3.17.2",
    "@lingui/macro": "3.17.2",
    "@react-native-community/eslint-config": "3.2.0",
    "@testing-library/jest-native": "4.0.13",
    "@testing-library/react-native": "11.3.0",
    "@tsconfig/react-native": "2.0.3",
    "@types/jest": "29.5.0",
    "@types/object-hash": "3.0.2",
    "@types/qs": "6.9.7",
    "@types/react": "18.0.28",
    "@types/react-native-vector-icons": "6.4.13",
    "@types/react-test-renderer": "18.0.0",
    "@types/semver": "^7.5.0",
    "babel-jest": "29.5.0",
    "babel-plugin-macros": "3.1.0",
    "detox": "20.5.0",
    "eslint": "8.36.0",
    "eslint-config-prettier": "8.8.0",
    "eslint-plugin-detox": "1.0.0",
    "eslint-plugin-react": "7.32.2",
    "eslint-plugin-react-native": "4.0.0",
    "jest": "29.5.0",
    "jetifier": "2.0.0",
    "metro-react-native-babel-preset": "0.73.7",
    "prettier": "2.8.8",
    "react-test-renderer": "18.0.0",
    "typescript": "4.8.4"
  },
  "jest": {
  ....
  }
}

app.json

{
  "name": "*",
  "displayName": "*",
  "react-native-google-mobile-ads": {
    "android_app_id": "*",
    "ios_app_id": "*",
    "delay_app_measurement_init": true,
  }
}

ios/Podfile

No response

android/build.gradle

No response

android/app/build.gradle

No response

android/settings.gradle

No response

AndroidManifest.xml

No response

rKatex commented 1 year ago

Hmm.. it seems the problem happens, when I do not confirm any vendor options.

Is this really the way to go? I guess many users will try to manage the options. And if they don't select some vendors (which they won't) they will see no ads?

I really don't know how an app could be monetized via ads then. Even more so when there is no way to check which vendors have been selected.

Ronald3217 commented 1 year ago

Hello, I found something similar, although in the form I accepted the options (without entering the custom options) the value I got was null, so even entering the options and checking all of them continued with the same thing.

After reading the documentation and trying different ways, I found the easiest solution.

Which is to use the selectPersonalisedAds variable that returns a boolean, in my case if the form is closed I set the value to false. I share the function I use:

const getUserConsent = async () => {
      const consentInfo = await AdsConsent.requestInfoUpdate();
      if (consentInfo.status === AdsConsentStatus.NOT_REQUIRED) {
        guardarUserPersonalizedAds(true)
        return
      }
      if (consentInfo.isConsentFormAvailable && consentInfo.status === AdsConsentStatus.REQUIRED) {
        await AdsConsent.showForm();
        return
      }

      if (consentInfo.status === AdsConsentStatus.OBTAINED) {
        const {
          selectPersonalisedAds,
          storeAndAccessInformationOnDevice,
        } = await AdsConsent.getUserChoices();
        console.log('Personalized Ads ' + selectPersonalisedAds)
        if (storeAndAccessInformationOnDevice === false) {
          /**
           * The user declined consent for purpose 1,
           * the Google Mobile Ads SDK won't serve ads.
           */
          guardarUserPersonalizedAds(false)
          return
        }
      // save user setting maybe true or false
        guardarUserPersonalizedAds(selectPersonalisedAds)
      }
    }
    getUserConsent()
TaylorDale commented 1 year ago

See some additional discussion @ https://github.com/invertase/react-native-google-mobile-ads/issues/274#issuecomment-1616329406

Re issues with potential issues on Apple submission.

I'm going to submit a build where if the user denies one or both of storage and basic ads permission (which as far as I can see, those are the conditions under which no ads at all are displayed), they are prompted to buy the full app or reconsider ad-choices.

Can't really see what else to do in this scenario. 🤷

github-actions[bot] commented 1 year ago

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.