Skip to content

Instantly share code, notes, and snippets.

@setou
Created August 13, 2012 07:37
Show Gist options
  • Save setou/3337821 to your computer and use it in GitHub Desktop.
Save setou/3337821 to your computer and use it in GitHub Desktop.
Titanium Mobile Nend/Appbank module
function ADCNendView() {
(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.setBool('TEST_OR_DEVELOPMENT',
((Ti.App.deployType=='test'||Ti.App.deployType=='development')?true:false));
// NEND/Appbank
Ti.App.Properties.setString('NEND_APIKEY', '<<YOUR APIKEY HERE>>');
Ti.App.Properties.setString('NEND_SPOTID', '<<YOUR SPOTID HERE>>');
Ti.App.Properties.setString('NEND_APIKEY_TEST',
'a6eca9dd074372c898dd1df549301f277c53f2b9');
Ti.App.Properties.setString('NEND_SPOTID_TEST', '3172');
})();
var nendAdModule = require('net.nend');
var apikey = Ti.App.Properties.getBool('TEST_OR_DEVELOPMENT')
? Ti.App.Properties.getString('NEND_APIKEY_TEST')
: Ti.App.Properties.getString('NEND_APIKEY');
var spotid = Ti.App.Properties.getBool('TEST_OR_DEVELOPMENT')
? Ti.App.Properties.getString('NEND_SPOTID_TEST')
: Ti.App.Properties.getString('NEND_SPOTID');
var self = nendAdModule.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'),
nendID : apikey,
spotID : spotid,
});
if (Ti.App.Properties.getBool('TEST_OR_DEVELOPMENT')) {
self.addEventListener('start',function(){
Ti.API.debug(new Date().toString() + ' nadViewDidFinishLoad');
});
self.addEventListener('load',function(){
Ti.API.debug(new Date().toString() + ' nadViewDidReceiveAd');
});
self.addEventListener('error',function(){
Ti.API.debug(new Date().toString() + ' nadViewDidFailToReceiveAd');
});
}
self.loadAd();
return self;
}
module.exports = ADCNendView;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment