PDA

View Full Version : AdMob integration



mrtedweb
23 Sep 2010, 6:18 PM
Has anyone ever integrated AdMob with Sencha Touch? I'm currently evaluating this and can't get the AdMob content embedded into a panel using update().

evant
23 Sep 2010, 6:25 PM
You might want to elaborate, for example, what format is the AdMob content in? How would you use it normally?

mrtedweb
23 Sep 2010, 7:17 PM
You might want to elaborate, for example, what format is the AdMob content in? How would you use it normally?


AdMob works by sending a request to a php script which returns something like the following:



<script type="text/javascript">
var admob_vars = {
"pubid": "a14c9a5deb8d583",
"ti": "ebd5b55d-87d5-4154-9d1f-179d46820247"
}
</script>
<script type="text/javascript" src="http://mm.admob.com/static/iphone/iadmob.js"></script>
<img src="http://p.admob.com/e0?rt=0&amp;z=1285281269.4653&amp;a=&amp;s=a14c9a5deb8d583&amp;o=91544197220355271285212666699128&amp;lt=0.055574021148682&amp;to=1" alt="" width="1" height="1"/>
I'm storing this into a variable called 'adContent' and trying to push this into a panel called 'adSpace' like this:


adSpace.update(adContent, true);I imagine it has something to do with the injected javascript, but that's why I'm using the optional statement of 'true' in the update statement. Any ideas?

evant
23 Sep 2010, 7:24 PM
The docs aren't correct in this case, currently Touch only supports inserting of the html, the dynamic script evaluation isn't included. You could pull that code from Ext if you wanted that functionality.

mrtedweb
23 Sep 2010, 7:32 PM
Understood. Thanks for the quick response.

ajethalia
26 Apr 2011, 1:18 AM
Understood. Thanks for the quick response.

Hi,

Were you able to integrate the code with your sencha touch app ? If yes, could you please help me out , I am also trying to do the exact same stuff but to no success.

mrtedweb
26 Apr 2011, 8:35 AM
I ended up abandoning this. Dynamically loading the Javascript proved to mess things up way too much for us to consider it.

ajethalia
26 Apr 2011, 9:41 PM
Thanks a lot for the prompt reply. You saved me from getting into this mess. :)

2bscene
27 Jul 2011, 11:58 AM
Might be too late to help, but I ended up using an iframe. http://www.tomdoyletalk.com/2011/07/27/sencha-touch-admob-phonegap/

Hope it helps!

Altxxv742
27 Jul 2011, 10:59 PM
<script type="text/javascript"> 
var admob_vars = { 
 pubid: 'xxxxxxxxxxx', // publisher id 
 bgcolor: '000000', // background color (hex) 
 text: 'FFFFFF', // font-color (hex) 
 test: true // test mode, set to false if non-test mode 
}; 

</script> 
<script type="text/javascript" src="http://mm.admob.com/static/iphone/iadmob.js"></script> 
</div> 


That pretty much works.

2bscene
27 Jul 2011, 11:37 PM
That pretty much works.

For me personally, I couldn't get it to display within a panel going that raw route. So I opted for the iframe and that worked out.

Subby
7 Aug 2011, 3:47 AM
Hi there folks,

Can you please, please, please help me as my app doesn't seem to display any adverts. All it does it show a white rectangle box.

This is the code in my sencha touch application:


var adverts = new Ext.Panel({
dock: 'bottom', // dock to the bottom
dockedItems: [{
html: '<iframe src =\"adverts.html" width=\"100%\" height=\"48\" frameBorder=\"0\" scrolling=\"no\"></iframe>', // dimensions for adverts
id: 'advert' // adverts ID: advert
}]
});

And this is my adverts html where I can to pull the javascript from:


<!DOCTYPE html><html>
<head>
<script type="text/javascript">
var admob_vars = {
pubid: '**********', // publisher id
bgcolor: '000000', // background color (hex)
text: 'FFFFFF', // 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>
</head>
<body>
</body>
</html>


Any help is appreciated.

2bscene
8 Aug 2011, 12:21 AM
Have you tested your code outside Sencha? E.g. open your adverts.html file in Safari using the iPhone User Agent?

Subby
8 Aug 2011, 1:54 AM
Hi,

Yes I tried it via the web url in my iPhones browsers AND Android browser....Still didn't work.

It must be my code. What am I doing wrong? Please take a look at it.

2bscene
8 Aug 2011, 3:04 AM
Hi Subby

I just checked your code there, you have the javascript in your head tag, it should be in the body of the page.

Also - make sure you have your publisher id in or it won't work either.

Subby
8 Aug 2011, 3:10 AM
Thanks Tom :P Hehe,

I'll check it now and see if it works. Thanks you so much for your help.

Subby
8 Aug 2011, 3:11 AM
By the way Tom. It's me who is contacting you on Your blog, Hehe :P Thanks once again! I'm trying it out now.

Subby
8 Aug 2011, 3:24 AM
AH, IT WORKED! AWESOME! Thank you so much.

One last thing though, please.

I put 48 pixels for height but the admob isn't covering it all completely. I can see a bit of white above and underneath the ads.

Any ideas?

Premier
8 Aug 2011, 12:17 PM
AH, IT WORKED! AWESOME! Thank you so much.

One last thing though, please.

I put 48 pixels for height but the admob isn't covering it all completely. I can see a bit of white above and underneath the ads.

Any ideas?

Please can you give me your example?