My code below:
var AdMobID = 'pub-7549374568441132';
var tmrAds = setTimeout(function() {
Ti.API.info('Requesting Ads...');
Admob = require('ti.admob');
Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_BEST;
Ti.Geolocation.distanceFilter = 0;
Ti.Geolocation.purpose = 'To show you local ads, of course!';
Ti.Geolocation.getCurrentPosition(function reportPosition(e) {
if (!e.success || e.error) {
// aw, shucks...
} else {
banner = Admob.createView({
top : 100,
left : 0,
width : 320,
height : 50,
publisherId : AdMobID, // You can get your own at http: //www.admob.com/
adBackgroundColor : 'black',
testing : true,
dateOfBirth : new Date(1985, 10, 1, 12, 1, 1),
gender : 'female',
keywords : '',
location : e.coords
});
//Set listeners
banner.addEventListener('didReceiveAd', function(e) {
Ti.API.info('New Ad');
banner.show();
});
banner.addEventListener('didFailToReceiveAd', function(e) {
Ti.API.info('New ad failed');
banner.hide();
});
//add now
viewBanner.add(banner);
$.Window.add(viewBanner);
}
});
}, 4500);
I have got the admob to work with a static advert, but it doesn't seem to be working with location based ads.
I have followed the instructions, as written in the app.js of the module.
Any idea why?
Cheers
↧