I am trying to get Admob to work with Titanium iOS App.
First of all I downloaded the Ti.admob module and integrated it to my app. I could see on the Titanium console while it's building that my app found Ti.Admob module, but nothing was shown on the simulator screen.
This is my code in ApplicationWindow.js
Titanium.Admob = require('ti.admob');
function ApplicationWindow(title) {
var currentwindow = Ti.UI.createWindow({
title:title,
backgroundColor:'red'
});
setAds(currentwindow);
return currentwindow;
};
module.exports = ApplicationWindow;
function setAds(currentwin)
{
var ad;
ad = Titanium.Admob.createView({
top: 50,
left: 0,
width: 320,
height: 50,
publisherId: '<MY API KEY>',
adBackgroundColor: 'black',
testing: true,
dateOfBirth: new Date(1981, 1, 1, 1, 1, 1),
gender: 'female',
keywords: 'test'
});
currentwin.add(ad);
ad.addEventListener('didReceiveAd', function() {
alert('Did receive ad!');
});
ad.addEventListener('didFailToReceiveAd', function() {
alert('Failed to receive ad!');
});
ad.addEventListener('willPresentScreen', function() {
alert('Presenting screen!');
});
ad.addEventListener('willDismissScreen', function() {
alert('Dismissing screen!');
});
ad.addEventListener('didDismissScreen', function() {
alert('Dismissed screen!');
});
ad.addEventListener('willLeaveApplication', function() {
alert('Leaving the app!');
});
}
And this is my Titanium console.
[INFO] One moment, building ...
[INFO] Detected third-party module: ti.admob/1.0
[INFO] Detected third-party module: ti.admob/1.0
[INFO] Titanium SDK version: 2.0.1 (04/12/12 16:33 999c68a)
[INFO] iPhone Device family: universal
[INFO] iPhone SDK version: 5.0
[INFO] iPhone simulated device: iphone
[INFO] Performing full rebuild. This will take a little bit. Hold tight...
[INFO] Performing clean build
[INFO] Compiling localization files
[INFO] Launching application in Simulator
[INFO] Launched application in Simulator (21.40 seconds)
[INFO] Application started
[INFO] testAdmob/1.0 (2.0.1.GA2.999c68a)
[INFO] AdMob module loaded