I recently created a small Android mobile app using Sencha Touch & Phonegap. The app was always going to be free as it does little more than give website owners the ability to check how their website is performing from a SEO and Social Media point of view.
I thought I might as well try and make a few bob from the app (oh the app is called My Web Performance and is available on Android Market) so the obvious option was sponsored adverts. And no place more obvious to use for sponsored ads, that Google. Google offer a program for mobile developers called Admob. Admob works pretty much along the same lines as Google Adsense in that you place Google Adsense on your website and you earn a % of the amount the advertiser is paying to place their ads on Google. Admob does this for mobile websites and applications etc.
The dilemma was that I couldn’t find out how to get this to work with Sencha Touch and Phonegap. I figured out a little hack in the end that seems to be working out for me so far. So for all you Sencha Touch users, here’s how I did it…
- Admob Set Up
In Admob – when adding a site, choose “Smartphone Web App”. This will present you with Javascript that we can use later. - Sencha Touch
Ok, the idea is to basically create a new toolbar that uses an iFrame to pull in a separate html file that contains the Admob code. So firstly, create a new HTML file called adverts and paste your Admob code into it.Then in your Sencha Touch application js file add the iFrame code where-ever you think it will sit best. My panel looks like this:var content = new Ext.Panel({ fullscreen: true, id: 'content', scroll: 'vertical', dockedItems: [{ id: 'status', xtype: 'toolbar', dock: 'top', title: "My Web Performance" }, actionPanel, { title: 'The Latest', html: '<iframe src =\"adverts.html" width=\"100%\" height=\"48\" frameBorder=\"0\" scrolling=\"no\"></iframe>', id: 'feedTab', border: false, dock: 'bottom', } ] });
- Phonegap
There’s really nothing out of the ordinary to do here – follow the usual steps and you should be laughing!
Enjoy!




#1 by Usmaan at August 8th, 2011
| Quote
Hi Tom,
Keep up the excellent work! It’s brilliant.
Quick question though…
I did exactly what you have done in this example but I don’t see any ads being displayed. Rather, all I see is a white rectangle box at the bottom of my app.
Of course, I haven’t structured the sencha code like you have since my app is different, but, that shouldn’t matter, or at least, I don’t think it should.
Please help >.>
#2 by Tom Doyle at August 8th, 2011
| Quote
Hi Usmaan
Can you should me some of your code so I can see if I can spot anything?
#3 by Premier at August 8th, 2011
| Quote
Can you share your code please?
Thank you.
#4 by Jon at September 2nd, 2011
| Quote
Dang it, exactly what I needed but I can’t get it to work. I too get a all white space where the adverts.html is supposed to show up. Seems Admob isn’t serving me with any ads. My adverts.html simply got [admob code here].
When you set up the Admob site you have to introduce an URL. My phonegap app of course doesn’t have any URL, could that be the issue? Admob only serving ads if the request comes from that very URL?
Uhh……
#5 by Jon at September 2nd, 2011
| Quote
Ok I know what’s happening here, while trying the App from the PC (chrome browser) Admob doesn’t provide any ads. When trying it from the phone it shows up.
#6 by Jon at September 4th, 2011
| Quote
Leaving test mode (i.e., test: false in the adverts.html) makes the white space come back, while during test mode I can see the test ad perfectly.
#7 by Tom Doyle at September 5th, 2011
| Quote
Hi Jon
It won’t work in a normal browser. You’ll to either test on the phone or use a user agent spoofer in your desktop browser.
#8 by Jon at September 5th, 2011
| Quote
Thanks Tom,
The problem seems to be AdMob serving me a horrible Fill Rate. 41 requests has given me only 1 impression. I have mailed AdMob support about this problem, let’s see what happens..
#9 by Tom Doyle at September 6th, 2011
| Quote
Hi Jon
Yes they’re notorious for the low fill rate (until of course your app is being used regularly)
40% fill rate isn’t too bad compared to some of the apps we have. Most have an average of 30%
Tom
#10 by John Spounias at January 6th, 2012
| Quote
excellent write up.
#11 by Marco Aguilar at June 22nd, 2012
| Quote
Thanks a lot man, I’ll be trying this out