以纯 JavaScript 显示 AdMob 广告(或其他广告提供商)的任何方式 [英] Any way to display AdMob ads (or other ad provider) in pure JavaScript

查看:23
本文介绍了以纯 JavaScript 显示 AdMob 广告(或其他广告提供商)的任何方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么方法可以仅使用纯 JavaScript 来展示 AdMob 广告?或者以任何其他方式,我可以直接在使用 PhoneGap Build 构建的 PhoneGap 应用程序中使用它?

Is there any way to display AdMob ads using only pure JavaScript? Or in any other way, that I can use it directly in PhoneGap application built with PhoneGap Build?

我正在使用 PhoneGap 开发移动应用程序.我已经看到了许多解决此问题的方法和方法(例如 this这个).但由于我只使用PhoneGap Build,我不能使用任何一个.我见过 AdMob Cordova 插件,但因为它是面向平台的(目前只有适用于 iOS 和 Android)并且在文档中有很多 Java 和 SDK,我很确定,我不能在使用 PhoneGap Build 编译的应用程序中使用它.

I'm developing mobile apps using PhoneGap. I've seen many solutions and approaches to this problem (like this or this). But since I'm using PhoneGap Build only, I can't use any of it. I've seen AdMob Cordova Plugin, but since it is platform-oriented (currently only available for iOS and Android) and has a lot of Java and SDK in documentation, I'm pretty sure, that I can't use it in app compiled with PhoneGap Build.

如果没有办法通过 JS 获取 AdMob,那么也许还有另一个广告提供者,哪个 API 可以完全通过 JavaScript 访问?

If there is no way to get AdMob via JS, then maybe there is another ad provider, which API is reachable entirely from JavaScript?

我听说 MillenialMedia 可以使用纯 JavaScript 展示广告,甚至允许外部广告提供商(如 AdMob).所以这对我来说是一个完美的解决方案.但是他们的页面组织得很差(大量的自我营销bla-bla,并且没有指向某些API,示例或文档的实际链接,至少没有,当您没有登录时),我无法确认它支持 JavaScript 和 AdMob.有人对此系统有任何经验并可以确认吗?

I've heard that MillenialMedia can display ads using pure JavaScript and even allows external ads providers (like AdMob). So this would be a perfect solution for me. But their page is so poorly organised (a lot of self-marketing bla-bla and no actual links to some API, examples or docs, at least no, when you're not logged in), that I can't confirm that it supports both JavaScript and AdMob. Does someone have any experience with this system and can confirm this?

推荐答案

有一个强大的 AdMob Plugin Pro(免费,尽管名称 pro 听起来很吓人),可以很容易地在 PhoneGap Build 中使用.我认为,这是解决这个问题的最先进的解决方案,因为 -- 使用 PhoneGap Build 的 npm 插件介绍 -- 您现在可以在纯 Javascript PhoneGap Build 应用程序中使用所有需要您使用其原生 SDK 的广告网络.

There's a powerful AdMob Plugin Pro (free, even though name pro sounds scary), that can be quite easily used in PhoneGap Build. I think, this is the state-of-art solution for this problem, because -- with introduction to npm plugins to PhoneGap Build -- you can now use in pure Javascript PhoneGap Build application all the ad networks, that require you to use their native SDKs.

关键优势(在这个问题的上下文中)——开箱即用的支持:

Key advantages (in context of this question) -- out-of-the-box support for:

  • PhoneGap Build(见下面的通知),
  • 许多广告类型,包括全屏广告,
  • 许多广告提供商和广告网络(带有插件,见下文),
  • 使用纯 JavaScript 投放广告,只需几行代码.

插件支持以下广告网络/提供商:

Plugin supports following ad networks / providers:

  • AdMob
  • DFP
  • Facebook 受众网络,
  • 乱舞,
  • iAd,
  • 在移动中,
  • 千禧年媒体,
  • MobFox.

前两个(粗体)具有开箱即用的支持,而所有其他都需要使用额外的 插件.

Where first two (in bold) has out-of-the-box support, while all other require use of additional plugins.

一篇文章在PhoneGap Build中使用这个插件.它有点过时了.您不应该使用现在已弃用的 plugins.cordova.io,而是新支持的 npm 存储库.为此,只需替换:

There's an article on using this plugin in PhoneGap Build. It is a bit out-dated. You should not use now deprecated plugins.cordova.io, but newly supported npm repository. For this, simply replace:

<gap:plugin name="com.google.cordova.admob" source="plugins.cordova.io" />

与:

<gap:plugin name="cordova-plugin-admobpro" source="npm"/>

插件的作者提供了一个可扩展文档,其中包括 API 文档、代码示例和不同开发平台之间的示例实现.真是好作品!

Plugin's author offers an extensible documentation which includes API documentation, code examples and example implementations among different development platforms. Really good piece of work!

资源:

这篇关于以纯 JavaScript 显示 AdMob 广告(或其他广告提供商)的任何方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆