1

I have a React-Native app which also has React-Native-Admob installed. I can see a banner inside my app without any problems. However I have some trouble with getting the Interstitial or Rewarded apps to be shown.

I prefer to get the rewarded ad showing so I'll start with this one. Users can upload pictures and information to the app for free. When clicking the report button a modal opens which asks if they want to pay of do it for free. If they choose for free the modal should close and a rewarded app should be shown. After viewing this the upload should start.

According to an example app I have to put these in ComponentdidMount, so I figured I would place them in a useEffect hook;

useEffect(() => {
    AdMobRewarded.setTestDevices([AdMobRewarded.simulatorId]);
    AdMobRewarded.setAdUnitID('ca-app-pub-3940256099942544/5224354917');

    AdMobRewarded.addEventListener('rewarded', reward =>
        console.log('AdMobRewarded => rewarded', reward),
    );
    AdMobRewarded.addEventListener('adLoaded', () =>
        console.log('AdMobRewarded => adLoaded'),
    );
    AdMobRewarded.addEventListener('adFailedToLoad', error =>
        console.warn(error),
    );
    AdMobRewarded.addEventListener('adOpened', () =>
        console.log('AdMobRewarded => adOpened'),
    );
    AdMobRewarded.addEventListener('videoStarted', () =>
        console.log('AdMobRewarded => videoStarted'),
    );
    AdMobRewarded.addEventListener('adClosed', () => {
        console.log('AdMobRewarded => adClosed');
        AdMobRewarded.requestAd().catch(error => console.warn(error));
    });
    AdMobRewarded.addEventListener('adLeftApplication', () =>
        console.log('AdMobRewarded => adLeftApplication'),
    );
    AdMobRewarded.requestAd().catch(error => console.warn(error));
}, [])

So when clicking the for free button in the modal the addUsingAdHandler is called for;

const addUsingAdHandler = () => {
    setIsAddMode(false)
    console.log('Rewared video is shown')
    AdMobRewarded.showAd().catch(error => console.warn(error));

However when I view this page I inmediatly receive a warning;

{"framesToPop":1, "code": "E_AD_FAILED_TO_LOAD","nativeStackIOS etc. etc.

Error: Cannot send request while another ad is being presented. Another rewarded ad may be requested after the current ad closes.
    at createErrorFromErrorData (utils.js:6)
    at RNAdMobRewarded.js:30
    at RCTDeviceEventEmitter.emit (EventEmitter.js:189)
    at MessageQueue.__callFunction (MessageQueue.js:366)
    at MessageQueue.js:106
    at MessageQueue.__guard (MessageQueue.js:314)
    at MessageQueue.callFunctionReturnFlushedQueue (MessageQueue.js:105)
    at RNDebuggerWorker.js:2

If I ignore this warning and click the for free button the modal is closed as expected, also my console log Rewarded video is shown. After the log however the Error: Ad is not ready to be shown.

So I thought this was because I was using the test ID's from Admob without having a rewarded ad activated on my account/app online. So I took the interstitial ad, which was activated a few days ago. This works without any warnings. However when the modal is closed and the ad should be shown nothing happend.

Can anyone guide me to get my Admob working with the rewarded? If requested I can change my code to the interstitial again and test that for you/show the code. React-native-cli: 2.0.1 React-native: 0.59.10 React-native-admob: 2.0.0-beta.6

MarkT
  • 97
  • 1
  • 11
  • So I tried my android app but this gives the same warnings and isn't showing apps. I copied in the app.js file content from the adMob example and the add showed without any problem. So it is in my code... I believe that I cannot use the AdMobRewarded.addEventListeners as I use them in the useEffect hook. Trial and erroring my way trought this. If anyone got this working with hooks or knows how to get it working I would like to know how. – MarkT Jan 10 '20 at 12:14
  • I'm now at the point that my android app is working as expected. Only the IOS app isn't working with the rewarded app. – MarkT Jan 12 '20 at 06:47
  • I receive same error when use Publisher Banner for ad Manager. Works in test but not in production. How do you fixed this on android? – Fernando Pascoal Gomes May 20 '20 at 15:11
  • Unfortunately I still haven't figured out a way to fix this. I further progressed trough the app and will look back into this at a later time. – MarkT May 21 '20 at 06:09

0 Answers0