首页 > 解决方案 > 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 原生编码。螺丝离子,螺丝混合编码。

标签: androidionic-frameworkadmob

解决方案


几天前找到了答案。只需降级科尔多瓦。我降级了很多东西,但忘记了科尔多瓦也可以/必须降级,以便一切都兼容。


推荐阅读