Created
August 13, 2012 04:42
-
-
Save setou/3337036 to your computer and use it in GitHub Desktop.
Titanium Mobile Admob module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ADCAdmobView() { | |
(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('ADMOB_ZINDEX', 20); | |
Ti.App.Properties.setBool('TEST_OR_DEVELOPMENT', | |
((Ti.App.deployType=='test'||Ti.App.deployType=='development')?true:false)); | |
Ti.App.Properties.setString('ADMOB_PUBID_IPHONE', '<<YOUR PUBLISHER ID HERE>>'); | |
})(); | |
var AdmobModule = require('ti.admob'); | |
//var isTesting = (Ti.Platform.model=='Simulator') ? true : false; | |
var isTesting = Ti.App.Properties.getBool('TEST_OR_DEVELOPMENT'); | |
var self = AdmobModule.createView({ | |
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'), | |
zindex : Ti.App.Properties.getInt('ADMOB_ZINDEX'), | |
adBackgroundColor: 'white', | |
testing : isTesting, | |
// testDevices : isTesting, | |
publisherId : Ti.App.Properties.getString('ADMOB_PUBID_IPHONE'), | |
}); | |
if (Ti.App.Properties.getBool('TEST_OR_DEVELOPMENT')) { | |
self.addEventListener('didReceiveAd', function() { | |
Ti.API.debug(new Date().toString() + ' didReceiveAd: Did receive ad!'); | |
}); | |
self.addEventListener('didFailToReceiveAd', function() { | |
Ti.API.debug(new Date().toString() + ' didFailToReceiveAd: Failed to receive ad!'); | |
}); | |
self.addEventListener('willPresentScreen', function() { | |
Ti.API.debug(new Date().toString() + ' willPresentScreen: Presenting screen!'); | |
}); | |
self.addEventListener('willDismissScreen', function() { | |
Ti.API.debug(new Date().toString() + ' willDismissScreen: Dismissing screen!'); | |
}); | |
self.addEventListener('didDismissScreen', function() { | |
Ti.API.debug(new Date().toString() + ' didDismissScreen: Dismissing screen!'); | |
}); | |
self.addEventListener('willLeaveApplication', function() { | |
Ti.API.debug(new Date().toString() + ' willLeaveApplication: Leaving the app!'); | |
}); | |
} | |
return self; | |
}; | |
module.exports = ADCAdmobView; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment