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
714 stars 150 forks source link

[🐛] Bug Report Title - config IDs when using app.config.js rather than app.json #370

Closed rafakwolf closed 1 year ago

rafakwolf commented 1 year ago

What happened?

the title is pretty self explanatory, but, how can I configure the ad ids when my config file is JS, not JSON

Platforms

Android and iOS

React Native Info

System:
    OS: macOS 13.3.1
    CPU: (8) arm64 Apple M2
    Memory: 75.19 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.19.1 - ~/.nvm/versions/node/v16.19.1/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.6.2 - ~/.nvm/versions/node/v16.19.1/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.12.0 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4
    Android SDK: Not Found
  IDEs:
    Android Studio: 2022.1 AI-221.6008.13.2211.9619390
    Xcode: 14.3/14E222b - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.18 - /opt/homebrew/opt/openjdk@11/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.71.6 => 0.71.6 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Are your using Typescript?

package.json

{
  "name": "my-project",
  "version": "1.9.9",
  "main": "index.js",
  "scripts": {
    "start": "expo start --dev-client",
    "android": "env-cmd -f .env.development expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "adb-logs": "$(which adb) logcat",
    "build-prod": "eas build --platform android --profile production --local",
    "build-dev": "eas build --platform android --profile development --local",
    "test": "jest"
  },
  "dependencies": {
    "@react-native-async-storage/async-storage": "1.17.11",
    "@react-native-community/netinfo": "9.3.7",
    "@react-navigation/drawer": "^6.5.7",
    "@react-navigation/native": "^6.1.2",
    "@react-navigation/native-stack": "^6.9.11",
    "@shopify/flash-list": "1.4.0",
    "@tanstack/react-query": "^4.26.1",
    "configcat-react": "^2.2.1",
    "expo": "~48.0.11",
    "expo-auth-session": "~4.0.3",
    "expo-background-fetch": "~11.1.1",
    "expo-constants": "~14.2.1",
    "expo-crypto": "~12.2.1",
    "expo-dev-client": "~2.2.1",
    "expo-device": "~5.2.1",
    "expo-notifications": "~0.18.1",
    "expo-splash-screen": "~0.18.1",
    "expo-sqlite": "~11.1.1",
    "expo-status-bar": "~1.4.4",
    "expo-task-manager": "~11.1.1",
    "expo-web-browser": "~12.1.1",
    "moti": "0.25.1",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "0.71.6",
    "react-native-adapty": "2.4.2",
    "react-native-gesture-handler": "~2.9.0",
    "react-native-google-mobile-ads": "9.1.2",
    "react-native-reanimated": "~2.14.4",
    "react-native-safe-area-context": "4.5.0",
    "react-native-screens": "~3.20.0",
    "react-native-svg": "13.4.0",
    "react-native-web": "~0.18.11",
    "rollbar-react-native": "^0.9.3",
    "typescript": "^4.9.4"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/plugin-proposal-export-namespace-from": "^7.18.9",
    "@expo/webpack-config": "^18.0.1",
    "@jest/globals": "^29.3.1",
    "@types/react": "~18.0.27",
    "@types/react-native": "^0.71.5",
    "jest": "^29.2.1"
  },
  "private": true,
  "overrides": {
    "@expo/config-plugins": "~6.0.1"
  }
}

app.json

{
  "expo": {
    "name": "",
    "description": "",
    "slug": "",
    "scheme": "",
    "version": "1.9.9",
    "icon": "./src/assets/icon.png",
    "assetBundlePatterns": [
      "**/*"
    ],
    "owner": "",
    "android": {
      "versionCode": 109090,
      "permissions": [
        "READ_EXTERNAL_STORAGE",
        "WRITE_EXTERNAL_STORAGE",
        "INTERNET",
        "RECEIVE_BOOT_COMPLETED",
        "WAKE_LOCK",
        "BILLING",
        "POST_NOTIFICATIONS",
        "ACCESS_NETWORK_STATE"
      ],
      "package": ""
    },
    "ios": {
      "bundleIdentifier": ""
    },
    "extra": {
      "eas": {
        "projectId": ""
      }
    }
  },
  "react-native-google-mobile-ads": {
    "android_app_id": "ca-app-pub-zzz",
    "ios_app_id": "ca-app-pub-zzzz"
  }
}

ios/Podfile

No response

android/build.gradle

No response

android/app/build.gradle

No response

android/settings.gradle

No response

AndroidManifest.xml

No response

Ahmed-Ibrahim-Anter commented 1 year ago

the same problem here

dylancom commented 1 year ago

The current package only works with app.json. Would be great if someone can submit a PR to add this functionality.

comontes commented 1 year ago

At the expo doctor step in Expo build, configuring the package in app.json causes the following issue:

✖ Validating Expo Config failed
Issues:
[stderr] 
Error: Problem validating fields in app.json. Learn more: https://docs.expo.dev/workflow/configuration/
[stderr] 
   • should NOT have additional property 'react-native-google-mobile-ads'.

The app still builds, but Expo doesn't like it

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.

FranciscoOssian commented 1 year ago

same problem, the lib doesn't support app.config.js

mikehardy commented 1 year ago

@FranciscoOssian

The current package only works with app.json. Would be great if someone can submit a PR to add this functionality.

We accept PRs! Cheers

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.

paradite commented 1 year ago

Just FYI, In expo you can have both app.config.js and app.json, so you can place the Ad ID in app.json while using app.config.js for other things. Of course this means you can't set the values dynamically for different packages like dev vs prod.

https://docs.expo.dev/workflow/configuration/

By default, Expo CLI will read the app.json first and send the normalized results to the app.config.js.

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.