0

我正在尝试让 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
4

1 回答 1

0

您没有在此代码中使用 admob 模块。您必须像这样更改 setAds 函数(注意 Admob.createView 而不是 Titanium.Admob.createView:

function setAds(currentwin) {
var Admob = require('ti.admob');
var ad;
ad = Admob.createView({
    top : 50, ........
于 2012-06-21T02:51:00.877 回答