Pau*_*ick 3 javascript admob react-native react-native-firebase firebase-admob
我正在使用 react-native-firebase / admob 在 react native 中使用 Adbmod,当我尝试在第一次点击时使用插页式广告时,它会打开广告,但从那时起它返回此错误:
Error: firebase.admob () InterstitialAd.show () The requested InterstitialAd has not loaded and could not be shown.
Run Code Online (Sandbox Code Playgroud)
代码与文档相同,可在此处找到:
基本上,您需要在查看广告后重新加载广告。因此,您可以添加一个 AdEventType.CLOSED 侦听器并在那里重新加载广告。
useEffect(() => {
const eventListener = interstitial.onAdEvent(type => {
if (type === AdEventType.LOADED) {
setLoaded(true);
}
if (type === AdEventType.CLOSED) {
console.log("ad closed");
setLoaded(false);
//reload ad
interstitial.load();
}
});
// Start loading the interstitial straight away
interstitial.load();
// Unsubscribe from events on unmount
return () => {
eventListener();
};
}, []);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
878 次 |
| 最近记录: |