Admob bannerView请求错误:没有要显示的广告

我在一个ios游戏的广告上看到了这个问题

这是我的代码,奇怪的是,如果我在request.testDevices列表中添加设备,它会显示演示横幅,如果我从testDevices中删除,它不会显示真正的横幅,但是如果我在XCODE上更改bundleIdentifier,它会显示真正的横幅,所以我相信它与我的admob帐户有关,有人得到过类似的东西吗

它总是会因以下错误而失败:

AdView didFailToReceiveAdWithError—————————————-错误域=com.google.ads代码=1“请求错误:没有要显示的广告。”用户信息={NSLocalizedDescription=请求错误:没有要显示的广告,.NSLocalizedFailureReason=请求错误:没有要显示的广告。}

在我的AppDelegate.m上

-(BOOL)应用程序:(UIApplication*)应用程序使用选项完成启动:(NSDictionary*)启动选项{
//使用Firebase库配置API
[FIRApp配置];
[[FiranalyticConfiguration sharedInstance]setAnalyticsCollectionEnabled:是];
//初始化谷歌移动广告SDK
[GADMobileAds配置应用程序ID:@“ca应用程序发布xx~xx”];
/*这里还有其他东西*/
}

在我的rootViewController.m上

//实现viewDidLoad以在加载视图后执行附加设置,通常从nib加载。
-(无效)viewDidLoad{
[超级视图下载];
bannerViewAdded=否;
间质性静脉曲张=否;
[自我添加横幅];
//……这里有更多的东西;
}
-(无效)添加横幅{
NSLog(@“调用添加横幅ROOTVIEWCONTROLLER”);
如果(!bannerViewAdded&![MKStoreManager已购买功能:kFeatureAId]){
NSLog(@“添加横幅ROOTVIEWCONTROLLER”);
CGSize size=[[CCDirector sharedDirector]winSize];
//创建adMob ad View(注意使用各种宏来检测设备)
if(IS|IPAD | IS|IPADHD){
bannerView=[[GADBannerView alloc]initWithAdSize:kGADAdSizeLeaderboard];
bannerView.center=CGPointMake(size.width/2,(size.height CGRectGetHeight(bannerView.frame)/2)-2);
}
否则如果(是iPhone 6){
bannerView=[[GADBannerView alloc]initWithAdSize:kGADAdSizeBanner];
bannerView.center=CGPointMake(size.width/2,(size.height CGRectGetHeight(bannerView.frame)/2)-2);
}
否则如果(是iPhone 6p){
bannerView=[[GADBannerView alloc]initWithAdSize:kGADAdSizeBanner];
bannerView.center=CGPointMake(size.width/2,(size.height CGRectGetHeight(bannerView.frame)/2)-2);
}
否则{
//无聊的旧iphone和ipodtouch
bannerView=[[GADBannerView alloc]initWithAdSize:kGADAdSizeBanner];
bannerView.center=CGPointMake(size.width/2,(size.height CGRectGetHeight(bannerView.frame)/2)-2);
}
//[bannerView setBackgroundColor:[UIColor blueColor]];
//需要将其设置为“否”,因为我们正在创建此自定义视图。
//bannerView.translatesAutoresizingMaskIntoConstraints=否;
//注意:编辑SampleConstants.h以提供KSAMPLEADUNID的定义
//在编译之前。
//将此广告单元ID替换为您自己的广告单元ID。
[email protected]“ca应用程序发布xx/xx”;
bannerView.rootViewController=self;
bannerView.delegate=self;
[self.view addSubview:bannerView];
GADRequest*请求=[GADRequest请求];
//[email protected][kgadsimulatid];
//[email protected][@“xx”,@“xx”,kGADSimulatorID];
[bannerView加载请求:请求];
bannerViewAdded=是;
}
}
-(无效)移除横幅{
//admob
如果(横幅被忽略){
bannerViewAdded=否;
[bannerView从SuperView移除];
[bannerView发布];
bannerView=无;
}
//没有AdMOB
如果(本地横幅){
localbanneraded=否;
[localBannerButton removeFromSuperview];
[localBannerButton释放];
localBannerButton=nil;
}
}
-(无效)额外的{
如果(!InterstitualVieWadded&![MKStoreManager已购买功能:kFeatureAId]){
NSLog(@“INIT interstitual ROOTVIEWCONTROLLER”);
InterstitualView=[[GadInterstitual alloc]initWithAdUnitID:@“ca app pub xx/xx”];
GADRequest*请求=[GADRequest请求];
//在指定的设备上请求测试广告。当
//发出广告请求。GadBanerView在服务器上运行时自动返回测试广告
//模拟器。
//[email protected][kGADSimulatorID,@“xxx”,“xxx”];
[中间视图加载请求:请求];
[中间视图集代理:self];
}
}
-(void)adView:(GADBannerView*)GADBannerView未接收到带有错误的数据:(GADRequestError*)错误{
NSLog(@“AdView didFailToReceiveAdWithError--------------------------------:%@”,错误);
[自我清除横幅];
如果(!localbanneraded){
CGSize size=[[CCDirector sharedDirector]winSize];
localBannerButton=[[UIButton按钮类型:UIButtonTypeRoundRect]retain];
localBannerButton.frame=CGRectMake(0.0,0.0320.0,50.0);
[localBannerButton设置标题:@“下载更多免费游戏”状态:UIControlStateNormal];
localBannerButton.backgroundColor=[UIColor whiteColor];//[UIColor clearColor];
[localBannerButton setTitleColor:[UIColor blackColor]用于状态:UIControlStateNormal];
[self.view addSubview:localBannerButton];
[localBannerButton setCenter:CGPointMake(self.view.center.x,(size.height-CGRectGetHeight(localBannerButton.frame)/2)-2];
//添加目标操作对
[localBannerButton addTarget:self action:@selector(openAppStore:)for ControlEvents:UIControlEventTouchUpInside];
localbanneraded=是;
}
}

我今天刚刚犯了这个错误,对我来说问题很简单,因为adUnitID基本上还是新的。在创建了adUnitID之后,我不得不等待2个多小时才能看到广告

如果您有此错误,并且您的adUnitIDs中的一些提供广告,而另一些没有。你很可能有同样的问题,唯一的解决办法就是等待

发表评论