如何将Google adsense放入iPhone应用程序?

时间:2010-05-30 10:41:44

标签: iphone adsense

我对adsense有疑问。 我想将Google adsense放入我的应用程序中进行开发。 但在测试我的代码之后,它没有显示出来。

这是我的代码

self.webView.userInteractionEnabled = NO;

NSMutableString *manageableHTML = [[[NSMutableString alloc] init] autorelease];

[manageableHTML appendFormat:@"<html><head></head>"];
[manageableHTML appendFormat:@"<body>"];
[manageableHTML appendFormat:@"<script type=\"text/javascript\"><!--"];
[manageableHTML appendFormat:@"window.googleAfmcRequest = {"];
[manageableHTML appendFormat:@"client: 'ca-mb-pub-7564235160823935',"];
[manageableHTML appendFormat:@"ad_type: 'text_image',"];
[manageableHTML appendFormat:@"output: 'html',"];
[manageableHTML appendFormat:@"channel: '2052458338',"];
[manageableHTML appendFormat:@"format: '320x50_mb',"];
[manageableHTML appendFormat:@"oe: 'utf8',"];
[manageableHTML appendFormat:@"color_border: '336699',"];
[manageableHTML appendFormat:@"color_bg: 'FFFFFF',"];
[manageableHTML appendFormat:@"color_link: '0000FF',"];
[manageableHTML appendFormat:@"color_text: '000000',"];
[manageableHTML appendFormat:@"color_url: '008000',"];
[manageableHTML appendFormat:@"};"];
[manageableHTML appendFormat:@"//--></script>"];
[manageableHTML appendFormat:@"<script type=\"text/javascript\" "];
[manageableHTML appendFormat:@"src=\"http://pagead2.googlesyndication.com/pagead/show_afmc_ads.js\"></script>"];
[manageableHTML appendFormat:@"</body></html>"];

[self.webView loadHTMLString:manageableHTML baseURL:nil];

[self.view addSubview:self.webView];

NSMutableString *manageableHTML = [[[NSMutableString alloc] init] autorelease]; [manageableHTML appendFormat:@"<html><head></head>"]; [manageableHTML appendFormat:@"<body>"]; [manageableHTML appendFormat:@"<script type=\"text/javascript\"><!--"]; [manageableHTML appendFormat:@"window.googleAfmcRequest = {"]; [manageableHTML appendFormat:@"client: 'ca-mb-pub-7564235160823935',"]; [manageableHTML appendFormat:@"ad_type: 'text_image',"]; [manageableHTML appendFormat:@"output: 'html',"]; [manageableHTML appendFormat:@"channel: '2052458338',"]; [manageableHTML appendFormat:@"format: '320x50_mb',"]; [manageableHTML appendFormat:@"oe: 'utf8',"]; [manageableHTML appendFormat:@"color_border: '336699',"]; [manageableHTML appendFormat:@"color_bg: 'FFFFFF',"]; [manageableHTML appendFormat:@"color_link: '0000FF',"]; [manageableHTML appendFormat:@"color_text: '000000',"]; [manageableHTML appendFormat:@"color_url: '008000',"]; [manageableHTML appendFormat:@"};"]; [manageableHTML appendFormat:@"//--></script>"]; [manageableHTML appendFormat:@"<script type=\"text/javascript\" "]; [manageableHTML appendFormat:@"src=\"http://pagead2.googlesyndication.com/pagead/show_afmc_ads.js\"></script>"]; [manageableHTML appendFormat:@"</body></html>"]; [self.webView loadHTMLString:manageableHTML baseURL:nil]; [self.view addSubview:self.webView];

Bofore测试,这个javascript代码在我的谷歌博客中运行良好。 我发现此代码仅适用于移动设备。 我通过我的ipod touch的safari检查了它。 (效果很好。)

但是在检查应用程序时,我没有看到adsense。 什么是错的?

1 个答案:

答案 0 :(得分:2)

如果你想要这种非法方法的替代品 - 你应该看一下AdMob,它为iPhone提供了一个可靠的应用内广告SDK。 (http://www.admob.com