Question

I am a mobile app developer, using the Cordova Framework. I want to integrate Google adMob in my projects without plugins. I want to use a simple Javascript code, because I will control better how and when to display ad banners on screen, in any operating systems: WP7, Android, iOS...

I found an old article (June 2011) that shows how do it. It uses this javascript file, but it doesn't works. I am trying this code:

<script type="text/javascript">
var admob_vars = {
  pubid: 'a1501b#######150', // publisher id
  bgcolor: 'FFFFFF', // background color (hex)
  text: '000000', // font-color (hex)
  test: true // test mode, set to false to receive live ads
};
</script>
<script type="text/javascript" src="http://mmv.admob.com/static/iphone/iadmob.js">
</script> 
<div style="position:absolute; z-index:999999; left:1px; top:100px; width:100%; height:100px; background-color:#e0e0e0; color:Blue;">
  [Google Ads div]
  <div id="admob_ad"></div>
</div>
<script>
    _admob.fetchAd(document.getElementById('admob_ad'));
</script>

Alternatively, I'd like to find a mobile ads agency that allows the use of Javascript files in my app mobile projects.

Was it helpful?

Solution

Well, I was trying to use the same javascript code. But it seems Google has withdrawn it's support for this method as mentioned here

Following is an excerpt from the page:

Please note that we are closing down AdMob Smartphone Web on May 1, 2012 and consolidating it with the main Google AdSense for content product.

This site will help to integrate adsense in Cordova. But it has it's limitations. Jquery mobile's ajax transitions are to be turned off for adsense to work!

So I'll be sticking with the Admob SDK till a better solution pops up.

Hope it helps.

Edit:

Today I came across InMobi ad network which support fetching ads through javascript. The JS code is here. Whereas InMobi's official comparison with Admob is here. So far I have not come across any ad mediation support by the InMobi network. But I guess I'll give it a try.

OTHER TIPS

I did a blog post which explains how to integrate AdMob into a Cordova app: AdMob and Cordova.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top