android - Ionic 4 中的 AdMobFree 4 根本不会在 banner.prepare() 中返回 Promise 对象
问题描述
我已经为此奋斗了好几天。我的呼吁:
this.admobFree.banner.prepare()
.then(() => {
// banner Ad is ready
// if we set autoShow to false, then we will need to call the show method here
})
.catch(e => console.log(e));
根本不会返回任何 Promise 对象,即永远不会触发“then”中的委托并且永远不会显示 AdMobFree 横幅。什么都没有出现。字符串调试从未更新为“xxx”,证明执行永远不会到达那里。
我的项目配置/设置:
降级为带有文件夹 /ngx 的版本 5 后,我有 AdMobFree 插件版本 4 对我根本不起作用 - 它一直说“对象不是函数”运行时错误。
我从 Ionic 6 降级到 5 和 4 只是希望在遵循了这么多建议但没有成功之后有更好的兼容性。
调用来自 ngOnInit,如下所示:
ngOnInit()
{
const bannerConfig: AdMobFreeBannerConfig = {
// add your config here
// for the sake of this example we will just use the test config
id: "ca-app-pub-3940256099942544/6300978111",
isTesting: true,
autoShow: true
};
this.admobFree.banner.config(bannerConfig);
this.admobFree.banner.prepare()
.then(() => {
// banner Ad is ready
// if we set autoShow to false, then we will need to call the show method here
})
.catch(e => console.log(e));
}
所有相关插件都已在该源文件和 app.module.ts 中正确导入。
我在这里真的需要帮助。否则,我几个月的工作将付诸东流,我将回到 Android 的 Java 原生编码。螺丝离子,螺丝混合编码。
解决方案
几天前找到了答案。只需降级科尔多瓦。我降级了很多东西,但忘记了科尔多瓦也可以/必须降级,以便一切都兼容。
推荐阅读
- c++ - 对使用 boost::beast 实现的 http rest 客户端进行单元测试
- excel - Excel VBA 对帐
- asp.net - 错误 CS1061: '列表
' 不包含尝试使用 ModelView 时的定义 - java - 数据库准备好后创建java bean
- unity3d - 为什么这些类会序列化为“{}”的 json
- javascript - 将线条添加到关联数组 Bar
- java - XJC - 具有相同名称元素的 XSD - 已定义错误
- java - SpringMVC 跨服务器上传文件 Handler dispatch failed;嵌套异常是 java.lang.NoClassDefFoundError: javax/ws/rs/ext/Providers
- nginx - 无法将 Http 重定向到 Https nginx
- node.js - 内容安全策略:页面设置阻止在 blob:https://...(“frame-src”)加载资源