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