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
651 stars 133 forks source link

rewarded ads are not loading giving error of not loaded #383

Closed usmanmalik333 closed 1 year ago

usmanmalik333 commented 1 year ago

What happened?

const [loaded, setLoaded] = useState(false);

const rewarded = RewardedAd.createForAdRequest(TestIds.REWARDED); useEffect(() => { if (!isDownload) { rewarded.load(); const unsubscribeLoaded = rewarded.addAdEventListener( RewardedAdEventType.LOADED, () => { setLoaded(true); console.log('Ads Loaded Successfully'); }, );

  const unsubscribeEarned = rewarded.addAdEventListener(
    RewardedAdEventType.EARNED_REWARD,
    reward => {
      console.log('reward', reward);
    },
  );

  return () => {
    unsubscribeLoaded();
    unsubscribeEarned();
  };
}

}, []);

const onPressWatchad = async () => {

rewarded.show();

}; useEffect(() => { if (!loaded) { rewarded.load(); } }, [loaded]);

giving error :

Possible Unhandled Promise Rejection (id: 1): Error: RewardedAd.show() The requested RewardedAd has not loaded and could not be shown.

Platforms

Only on Android

React Native Info

"react": "^18.2.0",
"react-native": "0.66.3",

Are your using Typescript?

package.json

{
  "name": "RelaxSoulApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "postinstall": "npx typesync",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint .",
    "yarnPlusNpm": "npm install && yarn",
    "testingRun": " react-native run-android --variant=sandboxDebug --appIdSuffix=sandbox",
    "debugsandbox": "react-native run-android --variant=sandboxDebug --appIdSuffix=sandbox",
    "debugrainsounds": "react-native run-android --variant=rainsoundsDebug --appIdSuffix=rainsounds",
    "debugcalmocean": "react-native run-android --variant=calmoceanDebug --appIdSuffix=calmocean",
    "debugcalmsounds": "react-native run-android --variant=calmsoundsDebug --appIdSuffix=calmsounds",
    "debugcalmbeachsounds": "react-native run-android --variant=calmbeachsoundsDebug --appIdSuffix=calmbeachsounds",
    "debugfireplace": "react-native run-android --variant=fireplaceDebug --appIdSuffix=fireplace",
    "debugbrainwaves": "react-native run-android --variant=brainwavesDebug --appIdSuffix=alpha.brainwaves.deepsleep",
    "debugwaterfallsounds": "react-native run-android --variant=serenewaterfallsoundsDebug --appIdSuffix=serenewaterfallsounds",
    "debugnightsounds": "react-native run-android --variant=nightsoundsDebug --appIdSuffix=nightsleep.sounds",
    "debugomsounds": "react-native run-android --variant=omsoundsDebug --appIdSuffix=omchanting.sounds"
  },
  "dependencies": {
    "@miblanchard/react-native-slider": "^2.2.0",
    "@react-native-async-storage/async-storage": "^1.15.8",
    "@react-native-community/hooks": "^2.8.1",
    "@react-native-community/slider": "^4.1.6",
    "@react-native-firebase/app": "^17.4.0",
    "@react-native-firebase/crashlytics": "^17.4.0",
    "@react-native-firebase/firestore": "^17.4.0",
    "@react-native-masked-view/masked-view": "^0.2.6",
    "@react-navigation/bottom-tabs": "^6.0.5",
    "@react-navigation/material-bottom-tabs": "^6.0.5",
    "@react-navigation/native": "^6.0.2",
    "@react-navigation/native-stack": "^6.1.0",
    "@react-navigation/stack": "^6.0.7",
    "@reduxjs/toolkit": "^1.6.1",
    "@types/react-native-base64": "^0.2.0",
    "add": "^2.0.6",
    "babel-plugin-root-import": "^6.6.0",
    "i": "^0.3.6",
    "lottie-ios": "3.4.0",
    "react": "^18.2.0",
    "react-native": "0.66.3",
    "react-native-background-timer": "^2.4.1",
    "react-native-base64": "^0.2.1",
    "react-native-config": "^1.4.4",
    "react-native-countdown-circle-timer": "^3.0.9",
    "react-native-countdown-component": "^2.7.1",
    "react-native-exit-app": "^1.1.0",
    "react-native-fast-image": "^8.5.11",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-google-mobile-ads": "^10.0.1",
    "react-native-iap": "^8.0.0-rc.6",
    "react-native-image-base64": "^0.1.4",
    "react-native-indicators": "^0.17.0",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-modal": "^13.0.0",
    "react-native-pager-view": "^5.4.1",
    "react-native-paper": "^4.9.2",
    "react-native-permissions": "^3.6.1",
    "react-native-progress": "^5.0.0",
    "react-native-reanimated": "^3.1.0",
    "react-native-responsive-screen": "^1.4.2",
    "react-native-router-flux": "^4.3.1",
    "react-native-safe-area-context": "^3.3.1",
    "react-native-screens": "^3.7.0",
    "react-native-scrollable-tab-view": "^1.0.0",
    "react-native-scrollable-tab-view-forked": "^1.1.3",
    "react-native-shimmer-placeholder": "^2.0.8",
    "react-native-skeleton-placeholder": "^5.0.0",
    "react-native-slider": "^0.11.0",
    "react-native-spinkit": "^1.5.1",
    "react-native-svg": "^12.1.1",
    "react-native-tab-view": "^3.1.1",
    "react-native-unimodules": "^0.14.8",
    "react-native-vector-icons": "^8.1.0",
    "react-native-volume-slider": "^0.5.1",
    "react-redux": "^7.2.5",
    "redux": "^4.1.1",
    "redux-thunk": "^2.3.0",
    "rn-fetch-blob": "^0.12.0",
    "yarn": "^1.22.17"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "@types/babel__core": "^7.1.16",
    "@types/eslint": "7.28.1",
    "@types/jest": "^27.0.1",
    "@types/react": "^17.0.20",
    "@types/react-native": "^0.64.13",
    "@types/react-native-background-timer": "^2.0.0",
    "@types/react-native-indicators": "^0.16.2",
    "@types/react-native-scrollable-tab-view": "^0.10.2",
    "@types/react-native-vector-icons": "^6.4.9",
    "@types/react-redux": "^7.1.19",
    "@types/react-test-renderer": "^17.0.1",
    "@types/rn-fetch-blob": "^1.2.2",
    "babel-jest": "^26.6.3",
    "babel-plugin-module-resolver": "^4.1.0",
    "eslint": "7.14.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.66.0",
    "react-native-codegen": "^0.0.7",
    "react-test-renderer": "17.0.2",
    "typescript": "^4.4.2"
  },
  "resolutions": {
    "stacktrace-parser": "0.1.4"
  },
  "jest": {
    "preset": "react-native"
  }
}

app.json

{
  "name": "RelaxSoulApp",
  "displayName": "RelaxSoulApp",
  "react-native-google-mobile-ads": {
    "android_app_id": "ca-app-pub-1574554177326430~8531642190"
  }
}

ios/Podfile

No response

android/build.gradle

No response

android/app/build.gradle

No response

android/settings.gradle

No response

AndroidManifest.xml

No response

application-inoviotech commented 1 year ago

Same Issue. Getting Reward Video Error : No fill from ad server. Failed to load ad. Please help if anyone can. App Open Ads, Banner Ads and Interstitial ads are working fine.

Using TestIds.Rewarded

usmanmalik333 commented 1 year ago

need solution for this

dylancom commented 1 year ago

@application-inoviotech This probably has nothing to do with this react native lib. Answer from the official Google Mobile Ads SDK team: "If the application is not published to the Play store, it is possible that you might have low fill rates which explains the no fill issue." See: https://groups.google.com/g/google-admob-ads-sdk/c/q7q9kKPvTAk

usmanmalik333 commented 1 year ago

My app is published to playstore and have more than 10k downloads @dylancom

usmanmalik333 commented 1 year ago

I'm getting this error : Possible Unhandled Promise Rejection (id: 1): Error: RewardedAd.show() The requested RewardedAd has not loaded and could not be shown. @dylancom

dylancom commented 1 year ago

Sounds like you're calling .show() too early?

usmanmalik333 commented 1 year ago

I'm calling it on button click @dylancom

usmanmalik333 commented 1 year ago

const onPressWatchad = async () => {

rewarded.show(); }; @dylancom

dylancom commented 1 year ago
if (loaded) {
  rewarded.show()
}
usmanmalik333 commented 1 year ago

this gives me always false @dylancom

dylancom commented 1 year ago

Maybe rewarded.load(); is never reached in your code?

usmanmalik333 commented 1 year ago

useEffect(() => { if (!isDownload) { rewarded.load(); const unsubscribeLoaded = rewarded.addAdEventListener( RewardedAdEventType.LOADED, () => { setLoaded(true); console.log('Ads Loaded Successfully'); }, );

const unsubscribeEarned = rewarded.addAdEventListener( RewardedAdEventType.EARNED_REWARD, reward => { console.log('reward', reward); }, );

return () => { unsubscribeLoaded(); unsubscribeEarned(); }; } }, []); this is my useeffect @dylancom

usmanmalik333 commented 1 year ago

this returns me always false @dylancom

usmanmalik333 commented 1 year ago

code don't goes in this function const unsubscribeLoaded = rewarded.addAdEventListener( RewardedAdEventType.LOADED, () => { setLoaded(true); console.log('Ads Loaded Successfully'); }, ); @dylancom

usmanmalik333 commented 1 year ago

need your help in this @dylancom

dylancom commented 1 year ago

As your code is in a conditional, might be that rewarded.load(); never gets called. It has to be something in your code, I just ran our example app and it is loading rewarded ads without problems.

Scherm­afbeelding 2023-05-15 om 12 34 26
usmanmalik333 commented 1 year ago

i have debug the code the rewarded.load(); is called but not load the ad @dylancom can i have your example code ?

dylancom commented 1 year ago

https://github.com/invertase/react-native-google-mobile-ads/tree/main/RNGoogleMobileAdsExample

usmanmalik333 commented 1 year ago

I'm Loading the ad in useeffect and showing it through button @dylancom

usmanmalik333 commented 1 year ago

Can we have video meet ? let me show you my code @dylancom

usmanmalik333 commented 1 year ago

I have implement the banner and interstitial ads both are working fine but rewarded ads are not working

usmanmalik333 commented 1 year ago

now getting this error: error reward [Error: [googleMobileAds/no-fill] No fill.]

usmanmalik333 commented 1 year ago

now getting this error: error reward [Error: [googleMobileAds/no-fill] No fill.] @dylancom

usmanmalik333 commented 1 year ago

@dylancom

usmanmalik333 commented 1 year ago

I'm getting this error my all other ads are working fine but in case of rewarded ads im getting this error : error reward [Error: [googleMobileAds/no-fill] No fill.] @dylancom @application-inoviotech @mikehardy @Ehesp Kindly need your help

mikehardy commented 1 year ago

Is your app published? You likely won't get fills fir that type unless it is published and you are using the published version

mikehardy commented 1 year ago

Also, please understand 7 posts like that is essentially spam. Please be reasonable with support expectations.

usmanmalik333 commented 1 year ago

yes my app is published and I'm using it with test ids @mikehardy My other all ads are working fine with test ids

limpanda7 commented 1 year ago

I have the same error. Surely I loaded an ad first and tried to show the ad, but it is said that I never loaded.

Ulisses1478 commented 1 year ago

I'm having this error too. Any solutions?

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.

student513 commented 11 months ago

I found a solution. I don't know exactly whether it's to prevent the abuse or for some reason, but after running rewarded.show(), you need a delay to prepare for the next rewareded ads

So you need a guard which won't run the show until the next rewarded ad is ready

const [loaded, setLoaded] = useState(false)

 const rewardedRef = useRef<RewardedAd | null>(null)

  useEffect(() => {
    const rewarded = RewardedAd.createForAdRequest(adUnitId, {
      requestNonPersonalizedAdsOnly: true, 
    })
    rewardedRef.current = rewarded

    const unsubscribeLoaded = rewarded.addAdEventListener(
      RewardedAdEventType.LOADED,
      () => {
        setLoaded(true)
      },
    )

    const unsubscribeEarned = rewarded.addAdEventListener(
      RewardedAdEventType.EARNED_REWARD,
      (reward) => {
        rewarded.removeAllListeners()
      },
    )

    rewarded.load()

    return () => {
      unsubscribeLoaded()
      unsubscribeEarned()
    }
  }, [])

  const onPressWatchad = () => {
    if (rewardedRef.current !== null) {
      if (loaded) { // <= add this
        rewardedRef.current.show()
        setLoaded(false) // <= add this
    }
  }
rss14 commented 10 months ago

Eu resolvi dessa forma...

Envolva seu código de exibição em um block try

function showAdsOnPress() { try { rewarded.show(); } catch (error) { console.log(Falhou ao abrir, error); rewarded.load(); } }