Skip to content

Instantly share code, notes, and snippets.

@setou
Created August 13, 2012 03:34
Show Gist options
  • Save setou/3336766 to your computer and use it in GitHub Desktop.
Save setou/3336766 to your computer and use it in GitHub Desktop.
Titanium Mobile AdView
function ADCIadView() {
(function() {
Ti.App.Properties.setInt('AD_TOP', 0);
Ti.App.Properties.setInt('AD_LEFT', 0);
Ti.App.Properties.setInt('AD_HEIGHT', 320);
Ti.App.Properties.setInt('AD_WIDTH', 50);
Ti.App.Properties.setInt('IAD_ZINDEX', 10);
Ti.App.Properties.setBool('TEST_OR_DEVELOPMENT',
((Ti.App.deployType=='test'||Ti.App.deployType=='development')?true:false));
})();
var self = Ti.UI.iOS.createAdView({
top : Ti.App.Properties.getInt('AD_TOP'),
left : Ti.App.Properties.getInt('AD_LEFT'),
height : Ti.App.Properties.getInt('AD_HEIGHT'),
width : Ti.App.Properties.getInt('AD_WIDTH'),
visible : true,
zIndex : Ti.App.Properties.getInt('IAD_ZINDEX'),
});
if (Ti.App.Properties.getBool('TEST_OR_DEVELOPMENT')) {
self.addEventListener('action', function(){
Ti.API.debug(new Date().toString() + ' iAd action!');
});
self.addEventListener('load', function(){
Ti.API.debug(new Date().toString() + ' iAd loaded!');
});
self.addEventListener('error', function(e){
Ti.API.debug(new Date().toString() + ' iAd error! message: ' + e.message);
});
}
return self;
}
module.exports = ADCIadView;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment