i was struggling with same problem for past 2 days and i just could get over it today.
this is the solution that works for me.
you should create a ref
from the RewardedAd.createForAdRequest()
instead of creating an object of it out of component's function. this way we can have a fresh new object of rewardedAd in our component.
const ComponentName = () => {
const rewardedAdRef = useRef(RewardedAd.createForAdRequest(TestIds.REWARDED));
const [adLoaded, setAdLoaded] = useState(false);
useEffect(() => {
const eventListener = rewardedAdRef.current.onAdEvent((type) => {
if (type === RewardedAdEventType.LOADED) setAdLoaded(true);
});
// Start loading the interstitial straight away
rewardedAdRef.current.load();
// Unsubscribe from events on unmount
return () => {
eventListener();
};
}, []);
if(adLoaded)
return <Button title="Show ad" onPress={() => rewardedAdRef.current.show()} />;
return null;
}
Thank you so much @Choco-Dev . your solution worked well.
If there is some problem with the library functionality and there is a working solution, please propose a PR! it will help everyone
i would like to help but i'm not familiar with the codes on this repo @mikehardy :) so i'm going to describe the way i could reproduce the problem for anyone who wants to work on it:
packages i was using with my RN project:
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 the community's attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
Still having the issue with @react-native-firebase/admob: 7.3.3
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 the community's attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.
Most helpful comment
i was struggling with same problem for past 2 days and i just could get over it today.
this is the solution that works for me.
you should create a
ref
from theRewardedAd.createForAdRequest()
instead of creating an object of it out of component's function. this way we can have a fresh new object of rewardedAd in our component.