我从此处的链接中集成了iAd / Admob显示代码:http://www.apptite.be/tutorial_mixing_ads.php 并有一些奇怪的结果。在admob上,我的点击率下降了40%,但展示次数保持不变。就像两个广告同时显示一样,iAds在admob广告之上。有没有人看到该网站上可能导致该问题的代码问题?
提前感谢您的帮助。
答案 0 :(得分:0)
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
NSLog(@"iAdBanner failed");
// Only request adMob when iAd did fail
[self adMobRequest];
在Apple的网站上,它表示“即使在向您的代表发送错误后,横幅视图仍继续尝试下载新广告。因此,实施这两种委托方法只允许您的应用程序显示横幅广告时广告已加载。“ (link)
我猜测正在发生的事情是,如果iAd失败,您正在展示AdMob广告,但之后iAd也会重试,因此如果它再次失败,它会请求另一个AdMob广告,尽管事实是一个人可能已经出现了?
答案 1 :(得分:0)
首先我们应该从谷歌下载Admob Sdk。 在google AdMob API中需要该文件: -
GADAdSize.h
GADBannerView.h
GADBannerViewDelegate.h
GADInterstitial.h
GADInterstitial.h
GADRequest.h
GADRequestError.h
libGoogleAdMobAds
#import <UIKit/UIKit.h>
#import "GADBannerViewDelegate.h"
@class GADBannerView, GADRequest;
@interface BannerExampleViewController : UIViewController
<GADBannerViewDelegate> {
GADBannerView *adBanner_;
}
@property (nonatomic, retain) GADBannerView *adBanner;
- (GADRequest *)createRequest;
@end
#import "BannerViewController.h"
#import "GADBannerView.h"
#import "GADRequest.h"
@implementation BannerExampleViewController
@synthesize adBanner = adBanner_;
#pragma mark init/dealloc
// Implement viewDidLoad to do additional setup after loading the view,
// typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
CGPoint origin = CGPointMake(0.0,
self.view.frame.size.height -
CGSizeFromGADAdSize(kGADAdSizeBanner).height);
self.adBanner = [[[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner
origin:origin]
autorelease];
self.adBanner.adUnitID = AdMob key;
self.adBanner.delegate = self;
[self.adBanner setRootViewController:self];
[self.view addSubview:self.adBanner];
[self.adBanner loadRequest:[self createRequest]];
}
- (void)dealloc {
adBanner_.delegate = nil;
[adBanner_ release];
[super dealloc];
}
#pragma mark GADRequest generation
- (GADRequest *)createRequest {
GADRequest *request = [GADRequest request];
request.testing = YES;
return request;
}
#pragma mark GADBannerViewDelegate impl
- (void)adViewDidReceiveAd:(GADBannerView *)adView {
NSLog(@"Received ad successfully");
}
- (void)adView:(GADBannerView *)view
didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(@"Failed to receive ad with error: %@", [error localizedFailureReason]);
}
@end