var Admob = require('ti.admob');
var bannerAdd = Admob.createView({
height : 50,
width : 320,
bottom : 40,
debugEnabled : false,
adType : Admob.AD_TYPE_BANNER,
adUnitId : 'ca-app-pub-3283366778120745/7674974318',
adBackgroundColor : '#7C181C',
estDevices : ['1CBA2C2A43588EB806AB1E74AD093760'], // You can get your device's id by looking in the console log
contentURL : 'https://www.google.com', // URL string for a webpage whose content matches the app content.
requestAgent : 'Titanium Mobile App', // String that identifies the ad request's origin.
extras : {
'version' : 1.0,
'name' : 'App'
},
publisherId : 'pub-3283366778120745',
tagForChildDirectedTreatment : false, // http:///business.ftc.gov/privacy-and-security/childrens-privacy for more infos
});
bannerAdd.addEventListener('didReceiveAd', function() {
Alloy.Globals.MotivationRadioNameSpace.printLogs('Did receive ad!');
});
bannerAdd.addEventListener('didFailToReceiveAd', function(e) {
Alloy.Globals.MotivationRadioNameSpace.printLogs('Failed to receive ad: ' + e.error);
});
bannerAdd.addEventListener('willPresentScreen', function() {
Alloy.Globals.MotivationRadioNameSpace.printLogs('Presenting screen!');
});
bannerAdd.addEventListener('willDismissScreen', function() {
Alloy.Globals.MotivationRadioNameSpace.printLogs('Dismissing screen!');
});
bannerAdd.addEventListener('didDismissScreen', function() {
Alloy.Globals.MotivationRadioNameSpace.printLogs('Dismissed screen!');
});
bannerAdd.addEventListener('willLeaveApplication', function() {
Alloy.Globals.MotivationRadioNameSpace.printLogs('Leaving the app!');
});
bannerAdd.addEventListener('didReceiveInAppPurchase', function(e) {
Alloy.Globals.MotivationRadioNameSpace.printLogs('Did receive an inApp purchase!');
Ti.API.warn(e);
});
$.mainWin.addEventListener('click', function(e) {
bannerAdd.requestAd();
});