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
686 stars 139 forks source link

Open Ads Appear after a permission or share dialogue opens #327

Closed zoobibackups closed 1 year ago

zoobibackups commented 1 year ago

What happened?

There is an issue with the open app ads. when ever there is permission dialogue likelocation, contact for storage dialogueopen by operating system or even an alert like Alert.alert() the app open ads appear. this is not the appropriate behaviour for google ads policy.

similarly there is another issue with ad open ads it appear with transparent background. with which native, banner or app contact is visible behind the open app ads.

another issue is that if the interstitial ads appear or inters tail video or rewarded ads the also open app ad appear.

similar on share dialogue open and after closing that open app ad appear.

I have done various thing to overcome these issue. some of theme resolve temporary but that is not a good solution.

is there an event with which we can check if the a system dialogue is open or some thing other.

  useEffect(() => {
      const subscription = AppState.addEventListener('change', nextAppState => {
        if (
          appState.current.match(/inactive|background/) &&
          nextAppState === 'active'
        ) {
          setTimeout(() => {
            if (AdState.canShowAppOpenAd && my_Screen != 'Places') {
              appOpenAd.loaded ? appOpenAd.show() : appOpenAd.load();
            } else {
              if (navigationScreen == 'Places') {
                AdState.canShowAppOpenAd = false;
              } else {
                AdState.canShowAppOpenAd = true;
              }
            }
          }, 1000);
        } else {
          appOpenAd.load();
        }

        appState.current = nextAppState;
        setAppStateVisible(appState.current);
      });
      return () => {
        subscription.remove();
      };
    }, []);

Platforms

Android and iOS

React Native Info

System:
    OS: macOS 13.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 7.21 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm
    Watchman: 2022.12.05.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /Users/apple/.rvm/gems/ruby-2.7.5/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.2 AI-212.5712.43.2112.8815526
    Xcode: 14.2/14C18 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.16 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.1.0 => 18.1.0 
    react-native: 0.70.6 => 0.70.6 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Are your using Typescript?

package.json

{
  "name": "NumberLocator",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint .",
    "postinstall": "patch-package"
  },
  "dependencies": {
    "@react-native-async-storage/async-storage": "^1.17.11",
    "@react-native-community/art": "^1.2.0",
    "@react-native-community/clipboard": "^1.5.1",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-native-community/netinfo": "^9.3.7",
    "@react-native-community/slider": "^4.4.0",
    "@react-navigation/drawer": "^6.5.6",
    "@react-navigation/native": "^6.1.1",
    "@react-navigation/native-stack": "^6.9.7",
    "@react-navigation/stack": "^6.3.10",
    "deprecated-react-native-prop-types": "^4.0.0",
    "geolib": "^3.3.3",
    "google-libphonenumber": "^3.2.31",
    "libphonenumber-js": "^1.10.15",
    "lottie-react-native": "^5.1.4",
    "patch-package": "^6.5.0",
    "postinstall-postinstall": "^2.1.0",
    "react": "18.1.0",
    "react-native": "0.70.6",
    "react-native-admob-native-ads": "^0.6.0",
    "react-native-android-location-enabler": "^1.2.2",
    "react-native-android-open-settings": "^1.3.0",
    "react-native-animatable": "^1.3.3",
    "react-native-app-intro-slider": "^4.0.4",
    "react-native-applovin-max": "^4.1.4",
    "react-native-battery": "^0.1.18",
    "react-native-compass-heading": "^1.4.2",
    "react-native-contacts": "^7.0.5",
    "react-native-cool-speedometer": "1.1.0",
    "react-native-device-info": "^10.3.0",
    "react-native-device-specs": "^0.0.7",
    "react-native-full-battery-status": "^0.1.10",
    "react-native-geolocation-service": "^5.3.1",
    "react-native-gesture-handler": "^2.8.0",
    "react-native-google-mobile-ads": "^8.2.2",
    "react-native-largelist-v3": "^3.1.0-rc.1",
    "react-native-linear-gradient": "^2.6.2",
    "react-native-maps": "^1.3.2",
    "react-native-maps-directions": "^1.9.0",
    "react-native-modal": "^13.0.1",
    "react-native-navigation-bar-color": "^2.0.2",
    "react-native-neomorph-shadows": "^1.1.2",
    "react-native-pager-view": "^6.1.2",
    "react-native-paper": "^5.1.2",
    "react-native-permissions": "^3.6.1",
    "react-native-reanimated": "^2.13.0",
    "react-native-responsive-fontsize": "^0.5.1",
    "react-native-safe-area-context": "^4.4.1",
    "react-native-screens": "^3.18.2",
    "react-native-send-intent": "^1.3.0",
    "react-native-splash-screen": "^3.3.0",
    "react-native-spring-scrollview": "3.0.2",
    "react-native-svg": "12.5.0",
    "react-native-svg-transformer": "^1.0.0",
    "react-native-system-setting": "^1.7.6",
    "react-native-torch": "^1.2.0",
    "react-native-vector-icons": "^9.2.0",
    "react-native-vitals": "^2.0.1"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.3",
    "eslint": "^7.32.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "0.72.3",
    "react-test-renderer": "18.1.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

app.json

{
  "name": "XYXZZZ",
  "displayName": "XYXZZZ",
  "react-native-google-mobile-ads": {
    "android_app_id": "ca-app-pub-1534832405428089~XXXX",
    "ios_app_id": "ca-app-pub-3940256099942544~XXXXX"
  }
}

ios/Podfile

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false

target 'NumberLocator' do
  config = use_native_modules!

  # Flags change depending on the env values.
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    # Hermes is now enabled by default. Disable by setting this flag to false.
    # Upcoming versions of React Native may rely on get_default_flags(), but
    # we make it explicit here to aid in the React Native upgrade process.
    :hermes_enabled => true,
    :fabric_enabled => flags[:fabric_enabled],
    # Enables Flipper.
    #
    # Note that if you have use_frameworks! enabled, Flipper will not work and
    # you should disable the next line.
    :flipper_configuration => FlipperConfiguration.enabled,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target 'NumberLocatorTests' do
    inherit! :complete
    # Pods for testing
  end

  post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

android/build.gradle

No response

android/app/build.gradle

No response

android/settings.gradle

No response

AndroidManifest.xml

No response

dylancom commented 1 year ago

There is no issue with app open ads. The Appstate on android becomes "inactive|background" whenever you show an Alert or overlay and goes back to active upon closing it. You are showing an app open ad whenever Appstate becomes active...

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.