最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google adMob in Apache Cordova (PhoneGap) 2.0 without plugins - Stack Overflow

programmeradmin0浏览0评论

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=".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.

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./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.

Share Improve this question edited Nov 29, 2018 at 13:13 Luboš Turek 6,6559 gold badges42 silver badges50 bronze badges asked Aug 4, 2012 at 8:55 rioflyriofly 1,7753 gold badges19 silver badges42 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 5 +50

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 parison with Admob is here. So far I have not e across any ad mediation support by the InMobi network. But I guess I'll give it a try.

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

发布评论

评论列表(0)

  1. 暂无评论