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
625 stars 121 forks source link

[🐛] Bug Report Title - Rewarded ads often do not load. #545

Closed KiyeopYang closed 4 months ago

KiyeopYang commented 4 months ago

What happened?

I am using rewarded ads, but often encounter issues where they do not load. It's not that they never appear. We receive and process about 20,000 requests daily.

However, there are frequent instances where the ads do not load at all. Users have reported these errors directly to me, and I have also experienced it multiple times myself.

The code is correct because majority of users do not have trouble seeing ads.

const ad2 = await RewardedAd.createForAdRequest(
    __DEV__
      ? TestIds.REWARDED
      : Platform.OS === 'android'
        ? env.ad.android.reward
        : env.ad.ios.reward,
    {
      requestNonPersonalizedAdsOnly: false,
    }
  );
  ad2.load();

  const unsubscribe1 = ad2.addAdEventListener(
    RewardedAdEventType.LOADED,
    () => {
      console.log('THIS MUST BE CALLED BUT NOT CALLED');
    }
  );

Platforms

Android and iOS

React Native Info

info Fetching system and libraries information...
System:
  OS: Windows 11 10.0.22621
  CPU: "(16) x64 AMD Ryzen 7 5800X 8-Core Processor             "
  Memory: 22.14 GB / 39.91 GB
Binaries:
  Node:
    version: 20.11.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.19
    path: ~\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 10.2.4
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK:
    AllowAllTrustedApps: Disabled
    Versions:
      - 10.0.19041.0
      - 10.0.22000.0
IDEs:
  Android Studio: Not Found
  Visual Studio: Not Found
Languages:
  Java: Not Found
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.6
    wanted: 0.72.6
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

info React Native v0.73.4 is now available (your project is running on v0.72.6).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.73.4
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.72.6
info For more info, check out "https://reactnative.dev/docs/upgrading?os=windows&platform=android".

Are your using Typescript?

package.json

{
  "name": "asdasdasd",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "start": "expo start"
  },
  "dependencies": {
    "@config-plugins/react-native-branch": "6.0.0",
    "@expo/config-plugins": "^7.2.2",
    "@expo/prebuild-config": "~6.2.4",
    "@expo/react-native-action-sheet": "^4.0.1",
    "@expo/vector-icons": "^13.0.0",
    "@react-native-async-storage/async-storage": "1.18.2",
    "@react-native-community/netinfo": "^11.2.1",
    "@react-native-community/slider": "4.4.2",
    "@react-native-firebase/analytics": "^18.3.2",
    "@react-native-firebase/app": "^18.3.2",
    "@react-native-firebase/crashlytics": "^18.3.2",
    "@react-native-firebase/perf": "^18.3.2",
    "@react-native-google-signin/google-signin": "^10.0.1",
    "@react-navigation/bottom-tabs": "^6.0.5",
    "@react-navigation/native": "^6.0.2",
    "@react-navigation/native-stack": "^6.1.0",
    "@react-navigation/stack": "^6.3.12",
    "@rneui/base": "^4.0.0-rc.7",
    "@rneui/themed": "^4.0.0-rc.7",
    "@sentry/react-native": "5.10.0",
    "@supabase/supabase-js": "^2.39.3",
    "axios": "^1.6.7",
    "base64-arraybuffer": "^1.0.2",
    "dayjs": "^1.11.10",
    "expo": "^49.0.22",
    "expo-apple-authentication": "~6.1.0",
    "expo-application": "~5.3.0",
    "expo-asset": "~8.10.1",
    "expo-auth-session": "~5.0.2",
    "expo-av": "~13.4.1",
    "expo-build-properties": "~0.8.3",
    "expo-clipboard": "~4.3.1",
    "expo-constants": "~14.4.2",
    "expo-dev-client": "~2.4.12",
    "expo-device": "~5.4.0",
    "expo-file-system": "~15.4.5",
    "expo-font": "~11.4.0",
    "expo-haptics": "~12.4.0",
    "expo-intent-launcher": "~10.7.0",
    "expo-linear-gradient": "~12.3.0",
    "expo-linking": "~5.0.2",
    "expo-localization": "~14.3.0",
    "expo-mail-composer": "~12.3.0",
    "expo-media-library": "~15.4.1",
    "expo-network": "~5.4.0",
    "expo-notifications": "~0.20.1",
    "expo-random": "~13.2.0",
    "expo-router": "^2.0.15",
    "expo-secure-store": "~12.3.1",
    "expo-sharing": "~11.5.0",
    "expo-splash-screen": "~0.20.5",
    "expo-status-bar": "~1.6.0",
    "expo-store-review": "~6.4.0",
    "expo-system-ui": "~2.4.0",
    "expo-task-manager": "~11.3.0",
    "expo-tracking-transparency": "~3.1.0",
    "expo-updates": "^0.18.19",
    "expo-web-browser": "~12.3.2",
    "i18n-js": "^4.3.2",
    "lottie-react-native": "5.1.6",
    "moti": "^0.26.0",
    "node-fetch": "^2.6.1",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "0.72.6",
    "react-native-branch": "5.9.0",
    "react-native-circular-progress": "^1.3.9",
    "react-native-fbsdk-next": "^12.1.3",
    "react-native-gesture-handler": "~2.12.0",
    "react-native-google-mobile-ads": "^12.1.1",
    "react-native-image-viewing": "^0.2.2",
    "react-native-modal": "^13.0.1",
    "react-native-pager-view": "6.2.0",
    "react-native-purchases": "^6.6.4",
    "react-native-reanimated": "^3.7.0",
    "react-native-safe-area-context": "4.6.3",
    "react-native-screens": "~3.22.0",
    "react-native-snackbar": "^2.6.2",
    "react-native-sse": "^1.1.0",
    "react-native-svg": "13.9.0",
    "react-native-tab-view": "^3.5.1",
    "react-native-url-polyfill": "^2.0.0",
    "react-native-uuid": "^2.0.1",
    "react-native-vector-icons": "^10.0.0",
    "react-native-view-shot": "3.7.0",
    "react-native-webview": "13.2.2",
    "react-query": "^3.39.2",
    "recoil": "^0.7.7",
    "sentry-expo": "~7.1.0",
    "use-debounce": "^9.0.4"
  },
  "devDependencies": {
    "@babel/core": "^7.20.2",
    "@babel/plugin-proposal-export-namespace-from": "^7.18.9",
    "@babel/plugin-proposal-optional-chaining": "^7.21.0",
    "@types/babel__core": "^7.20.0",
    "@types/react": "~18.2.14",
    "@types/react-dom": "18.0.10",
    "@types/react-test-renderer": "18.0.0",
    "@typescript-eslint/eslint-plugin": "^5.59.1",
    "@typescript-eslint/parser": "^5.59.1",
    "babel-plugin-transform-inline-environment-variables": "^0.4.4",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "eslint": "^8.39.0",
    "eslint-config-universe": "^11.2.0",
    "react-test-renderer": "18.1.0",
    "supabase": "^1.27.10",
    "typescript": "^5.1.3"
  },
  "private": true,
  "eslintConfig": {
    "extends": "universe/native"
  }
}

app.json

const buildNumber = 62;
const version = '0.1.57';
const bundleId = 'com.sadfsadf.app';

export default {
  expo: {
    name: 'asdfasfasdf',
    slug: 'asdfasdf',
    version,
    orientation: 'portrait',
    icon: './assets/images/forBuild/icon.png',
    scheme: 'asfasfasfd',
    userInterfaceStyle: 'light',
    backgroundColor: '#ffffff',
    splash: {
      image: './assets/images/forBuild/splash.png',
      resizeMode: 'cover',
      backgroundColor: '#ffffff',
    },
    updates: {
      fallbackToCacheTimeout: 0,
      url: 'https://u.expo.dev/d8b17229-b4f5-yuiyui-962c-9d7fa9fb5582',
    },
    'react-native-google-mobile-ads': {
      android_app_id: 'ca-app-pub-yuiyuiyui~1070356398',
      ios_app_id: 'ca-app-pub-yuiyuiyui~9381210816',
      user_tracking_usage_description:
        'This identifier will be used to deliver personalized ads to you.',
    },
    runtimeVersion: version,
    assetBundlePatterns: ['**/*'],
    ios: {
      bundleIdentifier: bundleId,
      supportsTablet: false,
      usesAppleSignIn: true,
      buildNumber: String(buildNumber),
      entitlements: {
        'com.apple.developer.networking.wifi-info': true,
      },
      googleServicesFile: './GoogleService-Info.plist',
      associatedDomains: [
        'applinks:yui.deeplink.page',
        'applinks:yui.page.link',
      ],
      config: {
        usesNonExemptEncryption: false,
      },

      infoPlist: {
        UIBackgroundModes: ['remote-notification'],
        CFBundleAllowMixedLocalizations: true,
      },
    },
    android: {
      package: bundleId,
      versionCode: buildNumber,
      adaptiveIcon: {
        foregroundImage: './assets/images/forBuild/adaptive-icon.png',
        backgroundColor: '#ffffff',
      },
      googleServicesFile: './google-services.json',
      playstoreUrl:
        'https://play.google.com/store/apps/details?id=com.yiuiyi.app',
      intentFilters: [
        {
          autoVerify: true,
          action: 'VIEW',
          data: { scheme: 'http', host: 'yuiyui.deeplink.page' },
          category: ['BROWSABLE', 'DEFAULT'],
        },
      ],
    },
    locales: {
      ko: './languages/ko.json',
      ja: './languages/ja.json',
    },
    plugins: [
      'sentry-expo',
      'expo-notifications',
      '@react-native-firebase/app',
      '@react-native-firebase/perf',
      '@react-native-firebase/crashlytics',
      'expo-localization',
      'expo-router',
      'expo-apple-authentication',
      '@react-native-google-signin/google-signin',
      [
        '@config-plugins/react-native-branch',
        {
          apiKey: 'hgyuiyguigyigyi',
          iosAppDomain: 'yguigyui.app.link',
        },
      ],
      [
        'expo-updates',
        {
          username: 'ghjkghjkghjk',
        },
      ],
      [
        'expo-build-properties',
        {
          ios: {
            useFrameworks: 'static',
          },
        },
      ],
      [
        'expo-tracking-transparency',
        {
          userTrackingPermission:
            'This identifier will be used to deliver personalized ads to you.',
        },
      ]
    ],
    extra: {
      eas: {
        projectId: 'd8b17229-b4f5-4b6f-962c-asdfasdfasfd',
      },
      supportsRTL: true,
    },
    hooks: {
      postPublish: [
        {
          file: 'sentry-expo/upload-sourcemaps',
          config: {
            organization: 'tyutyu',
            project: 'ryutryu',
          },
        },
      ],
    },
  },
};

ios/Podfile

No response

android/build.gradle

No response

android/app/build.gradle

No response

android/settings.gradle

No response

AndroidManifest.xml

No response

mikehardy commented 4 months ago

Interesting, you closed this, but what did you learn? It is an open source repo, run by contributed wisdom and code from all of us as users. What you learned may be interesting as a PR to the docs or at least here in the issues thread