|
var win = Ti.UI.createWindow(); |
|
|
|
// then create an adMob view |
|
var adMobView = Admob.createBannerView({ |
|
adUnitId: "ca-app-pub-3940256099942544/6300978111", |
|
testing:false, // default is false |
|
//top: 10, //optional |
|
//left: 0, // optional |
|
//right: 0, // optional |
|
bottom: 0, // optional |
|
width: "100%", |
|
height: 50, |
|
adBackgroundColor:"FF8855", // optional |
|
backgroundColorTop: "738000", //optional - Gradient background color at top |
|
borderColor: "#000000", // optional - Border color |
|
textColor: "#000000", // optional - Text color |
|
urlColor: "#00FF00", // optional - URL color |
|
linkColor: "#0000FF" //optional - Link text color |
|
//primaryTextColor: "blue", // deprecated -- now maps to textColor |
|
//secondaryTextColor: "green" // deprecated -- now maps to linkColor |
|
|
|
}); |
|
|
|
|
|
//listener for adReceived |
|
adMobView.addEventListener(Admob.AD_RECEIVED,function(){ |
|
// alert("ad received"); |
|
Ti.API.info("ad received"); |
|
}); |
|
|
|
//listener for adNotReceived |
|
adMobView.addEventListener(Admob.AD_NOT_RECEIVED,function(){ |
|
//alert("ad not received"); |
|
Ti.API.info("ad not received"); |
|
}); |
|
|
|
|
|
var adRequestBtn = Ti.UI.createButton({ |
|
title:"Request an ad", |
|
top:"10%", |
|
height: "10%", |
|
width: "80%" |
|
}); |
|
|
|
adRequestBtn.addEventListener("click",function(){ |
|
adMobView.load({ |
|
extras: { |
|
adBackgroundColor:"FF8855", // optional |
|
backgroundColorTop: "738000", //optional - Gradient background color at top |
|
borderColor: "#000000", // optional - Border color |
|
textColor: "#000000", // optional - Text color |
|
urlColor: "#00FF00", // optional - URL color |
|
linkColor: "#0000FF" //optional - Link text color |
|
} |
|
}); |
|
}); |
|
|
|
var adRequestBtn2 = Ti.UI.createButton({ |
|
title: "Request a test ad", |
|
top: "25%", |
|
height: "10%", |
|
width: "80%" |
|
}); |
|
|
|
adRequestBtn2.addEventListener("click",function(){ |
|
adMobView.requestTestAd(); |
|
}); |
|
|
|
var getAAID = Ti.UI.createButton({ |
|
title: "Get AAID", |
|
top: "40%", |
|
height: "10%", |
|
width: "80%" |
|
}); |
|
|
|
var getIsAdTrackingLimited = Ti.UI.createButton({ |
|
title: "Is Ad tracking limited", |
|
top: "55%", |
|
height: "10%", |
|
width: "80%" |
|
}); |
|
|
|
getAAID.addEventListener('click', function() { |
|
Admob.getAndroidAdId(function (data) { |
|
Ti.API.info('AAID is ' + data.aaID); |
|
}); |
|
}); |
|
|
|
getIsAdTrackingLimited.addEventListener('click', function() { |
|
Admob.isLimitAdTrackingEnabled(function (data) { |
|
Ti.API.info('Ad tracking is limited: ' + data.isLimitAdTrackingEnabled); |
|
}); |
|
}); |
|
|
|
win.add(adMobView); |
|
win.add(adRequestBtn); |
|
win.add(adRequestBtn2); |
|
win.add(getAAID); |
|
win.add(getIsAdTrackingLimited); |
|
win.open(); |