javascript - 错误:firebase.admob() InterstitialAd.show() 请求的 InterstitialAd 尚未加载,无法显示
问题描述
我正在使用 react-native-firebase / admob 在 react native 中使用 Adbmod,当我尝试在第一次点击时使用插页式广告时,它会打开广告,但从那时起它返回此错误:
Error: firebase.admob () InterstitialAd.show () The requested InterstitialAd has not loaded and could not be shown.
该代码与文档相同,可在此处找到:
解决方案
基本上,您需要在查看广告后重新加载广告。因此,您可以添加一个 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();
};
}, []);
推荐阅读
- java - 在 java gradle 项目中使用 liquibase
- python - Creating savepoints and starting from a specific node in apache beam
- addeventlistener - 收听 Firefox WebExtension 侧边栏关闭
- java - 用 Kotlin 数据类替换 Java DTO 类的问题
- javascript - 使用正文执行获取请求 - 节点 js
- vba - 缺少所需列的 vba 错误处理
- php - PHP中的喜欢/不喜欢系统
- git - 需要在 git remote 上恢复提交
- php - Nginx、PHP - 发生错误。抱歉,您要查找的页面目前不可用。请稍后再试
- swift - 具有慢速互联网连接的 avplayer 在第一帧后无法正常工作