Any way to display AdMob ads (or another ad provider) in pure JavaScript

Can I serve AdMob ads using pure JavaScript only? Or in some other way, can I use it directly in a PhoneGap application built with PhoneGap Build?

I am developing mobile applications using PhoneGap. I have seen many solutions and approaches to this problem (for example, this or this ). But since I only use PhoneGap Build, I cannot use it. I saw the AdMob Cordova plugin , but since it is platform-oriented (currently available only for iOS and Android) and the documentation has a lot of Java and SDKs, I am sure that I can not use it in an application compiled using PhoneGap Build .

If there is no way to get AdMob through JS, maybe there is another ad provider, which API is fully accessible from JavaScript?

I heard that MillenialMedia can serve ads using pure JavaScript and even allows third-party ad providers (like AdMob). So that would be the perfect solution for me. But their page is so poorly organized (a lot of bla-bla self-marketing and no actual links to some APIs, examples or documents, at least not when you are not logged in), that I canโ€™t confirm that it supports JavaScript and AdMob . Does anyone have experience with this system and can confirm this?

+6
source share
4 answers

There is a powerful AdMob Plugin Pro (free, although the name pro sounds scary), which can be used in PhoneGap Build. I think this is a modern solution to this problem, because - with an introduction to npm plugins in PhoneGap Build - you can now use all ad networks that require you to use your own SDKs in the clean Javascript PhoneGap Build application.

Key benefits (in the context of this question) - ready-made support for:

  • Phonegap build (see below),
  • many types of ads, including full-screen ads,
  • many advertising providers and ad networks (with plugins, see below),
  • Serving ads using pure Javascript with multiple lines of code.

The plugin supports the following ad networks / providers:

  • Admob
  • Dfp
  • Facebook Audience Network,
  • Flurry
  • OVR,
  • InMobi,
  • Millennial Media,
  • MobFox

In cases where the first two (shown in bold) have built-in support, and for others - the use of additional plug-ins .

Here's an article about using this plugin in PhoneGap Build . This is a bit outdated. You should not use the now obsolete plugins.cordova.io , but the recently supported npm repository . To do this, simply replace:

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

with:

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

The author of the plugin offers extensible documentation , which includes API documentation, code examples, and implementation examples of various development platforms. Really nice job!

Resources

+2
source

tl; dr Displaying mobile ads using pure Javascript:

I went through this a long time, and your request (JavaScript code), unfortunately, is not available with either mMedia or AdMob.

mMedia : They have the following types of source code for a mobile website (not an Android app): ASP, Perl, PHP, JSP5, ruby โ€‹โ€‹on rails and vb.net. in order to get the source code, you need a mobile website and the mobile website must be approved by mMedia, then you will receive real-time advertisements, and I think if you would use the source code of the website in your Android application, their account will be suspended because in mMedia each project must be approved first so that they expect their ads to appear in the project that they approved. And in any case, the JavaScript code is missing. mMedia will provide with sdk instructions for downloading and installing in your application, after which the ads will be displayed live, and I think you do not want to.

AdMob : itโ€™s a bit confusing to read about them, because in the past they used ads using the JavaScript method intended for but after Google buys the company, they deleted it and AdMob no longer serves the mobile site, and for the mobile website they advise you to use adsense. which confuses him, that there is still an instruction for installing JavaScript AdMob, which no longer exists. I saw your links, and I think you're trying to install the AdMob app for iOS. I did it for an Android application that was straightforward and it was easy to use In-App-Advertisements , but the problem is that I am ever trying to show it below.

AdSense : they have a JavaScript method, but they do not allow it to be used in mobile applications, and if they find out they will be blocked by your account ( details ).

for MobFox : they serve for advertising for a mobile website, and for source code for a mobile website: JavaScript, PHP, cURL, PHP, fSocket, J2SE 1.4, CGI / Perl and ASP.NET. and for the application you need to download the SDK. but thereโ€™s nothing in MobFox that you cannot use your JavaScript for a mobile application, and they work like Google after you are approved, you will receive a publisher ID and do whatever you want without violating their terms. Unlike mMedia, they must first approve everything. And they have the mediation option in the advertising network for the following companies: 4INFO, Aditic (Sofialys), Adfonic, AdMarvel, Admoda, BuzzCity, Hunt, mobile ads, InMobi, iVdopia, JumpTap, Komli Mobile (ZestAdz), Lumata Group (bMobile) , m-perf, Madvertise, MdotM, MobGold, MobPartner, Mocean, Mojiva, Nexage Exchange, Smaato, TapIt !, Vserv, WapStart, YOC performance (Mocean platform), YOC performance (Ubiyoo platform)

As for my research, the only option you have for JavaScript code will be with MobFox, and you need a way to get approval so that you have a publisher ID. I have a mobile website containing 4 pages with little traffic, such as 20 per day, and I got approval.

+5
source

You can try InMobi, where you only need 3 lines of Javascript ( details ).

0
source

Check out the AdMob Mobile Guide .

I did not know that they had such an API until I caught it.

-1
source

All Articles