iOS DFP广告管理系统(DFP)..错误:无广告显示

时间:2014-04-11 12:44:59

标签: ios objective-c ipad google-dfp

我在我的应用中使用DFP广告管理系统(DFP)。我按照DOCs进行了整合,如下所示。

 dfpBannerView_ = [[DFPBannerView alloc] initWithAdSize:kGADAdSizeBanner];
 dfpBannerView_.adUnitID = kSampleAdUnitID;
// Set the delegate to listen for GADBannerViewDelegate events.
dfpBannerView_.delegate = self;

// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.
dfpBannerView_.rootViewController = self;
[self.view addSubview:dfpBannerView_];

// Initiate a generic request to load it with an ad.
[dfpBannerView_ loadRequest:[GADRequest request]];

其中kSampleAdUnitID是我创建的应用单元ID。

以下委托方法是getcalled

- (void)adView:(DFPBannerView *)view
didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(@"Failed to receive ad with error: %@", [error localizedFailureReason]);
NSLog(@"%d",error.code);
}

但我仍然得到如下错误,

Failed to receive ad with error: Request Error: No ad to show.
2014-04-11 17:40:55.836 DFPBannerExample[6319:70b] 1

错误代码1代表/// The ad request was successful, but no ad was returned. kGADErrorNoFill,

我没有得到问题所在。为什么我没有获得广告,而我正在获取样本应用单元ID的广告。

1 个答案:

答案 0 :(得分:0)

如果您希望横幅显示某些内容,则需要指定横幅尺寸,然后使用adunit ID标记横幅:请检查以下代码:

 bannerView_ = [[DFPBannerView alloc] initWithFrame:CGRectMake(111, 483, 537, 120)];

bannerView_.adUnitID = @"/5900406/UserAppWaitingView";

// the user wherever the ad goes and add it to the view hierarchy.

bannerView_.rootViewController = self; [self.view addSubview:bannerView _];

// Initiate a generic request to load it with an ad.

[bannerView_ loadRequest:[GADRequest request]];