我正在尝试让 Admob 与 Titanium iOS App 一起使用。
首先,我下载了 Ti.admob 模块并将其集成到我的应用程序中。在构建时,我可以在 Titanium 控制台上看到我的应用程序找到了 Ti.Admob 模块,但模拟器屏幕上没有显示任何内容。
这是我在 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!');
});
}
这是我的 Titanium 控制台。
[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