我在一个ios游戏的广告中遇到了这个问题
这是我的代码,奇怪的是,如果我将设备添加到request.testDevices列表中,它会显示演示横幅,如果我从testDevices中删除,它不会显示真正的横幅,但如果我在XCODE上更改我的bundleIdentifier,它会显示真正的横幅,所以我相信这是我的admob帐户的东西,有人得到过类似的东西吗?
它总是失败,并显示以下错误:
AdView didFailToReceiveAdWithError -:Error Domain=com.google.ads Code=1“请求错误:没有广告可显示。”UserInfo={NSLocalizedDescription=Request错误:没有广告可显示,NSLocalizedFailureReason=Request错误:没有广告可显示。}
在我的AppDelegate.m上
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Use Firebase library to configure APIs
[FIRApp configure];
[[FIRAnalyticsConfiguration sharedInstance] setAnalyticsCollectionEnabled:YES];
// Initialize Google Mobile Ads SDK
[GADMobileAds configureWithApplicationID:@"ca-app-pub-xx~xx"];
/* other stuff here... */
}在我的rootViewController.m
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
bannerViewAdded = NO;
interstitialViewAdded = NO;
[self addBanner];
// ..... more stuff here;
}
- (void)addBanner{
NSLog(@"CALL ADD BANNER ROOTVIEWCONTROLLER");
if(!bannerViewAdded && ![MKStoreManager isFeaturePurchased:kFeatureAId]){
NSLog(@"ADD BANNER ROOTVIEWCONTROLLER");
CGSize size = [[CCDirector sharedDirector] winSize];
// Create adMob ad View (note the use of various macros to detect device)
if (IS_IPAD || IS_IPADHD) {
bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeLeaderboard];
bannerView.center = CGPointMake(size.width/2, (size.height-CGRectGetHeight(bannerView.frame)/2)-2);
}
else if (IS_IPHONE6) {
bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
bannerView.center = CGPointMake(size.width/2, (size.height-CGRectGetHeight(bannerView.frame)/2)-2);
}
else if (IS_IPHONE6P) {
bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
bannerView.center = CGPointMake(size.width/2, (size.height-CGRectGetHeight(bannerView.frame)/2)-2);
}
else {
// boring old iPhones and iPod touches
bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
bannerView.center = CGPointMake(size.width/2, (size.height-CGRectGetHeight(bannerView.frame)/2)-2);
}
//[bannerView setBackgroundColor:[UIColor blueColor]];
// Need to set this to no since we're creating this custom view.
//bannerView.translatesAutoresizingMaskIntoConstraints = NO;
// Note: Edit SampleConstants.h to provide a definition for kSampleAdUnitID
// before compiling.
// Replace this ad unit ID with your own ad unit ID.
bannerView.adUnitID = @"ca-app-pub-xx/xx";
bannerView.rootViewController = self;
bannerView.delegate = self;
[self.view addSubview:bannerView];
GADRequest *request = [GADRequest request];
//request.testDevices = @[ kGADSimulatorID ];
//request.testDevices = @[ @"xx", @"xx" , kGADSimulatorID ];
[bannerView loadRequest:request];
bannerViewAdded = YES;
}
}
- (void)removeBanner {
//admob
if(bannerViewAdded){
bannerViewAdded = NO;
[bannerView removeFromSuperview];
[bannerView release];
bannerView = nil;
}
//No AdMOB
if(localBannerAdded){
localBannerAdded = NO;
[localBannerButton removeFromSuperview];
[localBannerButton release];
localBannerButton = nil;
}
}
- (void)addInterstitial{
if(!interstitialViewAdded && ![MKStoreManager isFeaturePurchased:kFeatureAId]){
NSLog(@"INIT INTERSTITIAL ROOTVIEWCONTROLLER");
interstitialView = [[GADInterstitial alloc] initWithAdUnitID:@"ca-app-pub-xx/xx"];
GADRequest *request = [GADRequest request];
// Requests test ads on devices you specify. Your test device ID is printed to the console when
// an ad request is made. GADBannerView automatically returns test ads when running on a
// simulator.
//request.testDevices = @[ kGADSimulatorID, @"xxx", @"xxx" ];
[interstitialView loadRequest:request];
[interstitialView setDelegate:self];
}
}
- (void)adView:(GADBannerView *)gadBannerView didFailToReceiveAdWithError:(GADRequestError *)error{
NSLog(@"AdView didFailToReceiveAdWithError --------------------------- : %@", error);
[self removeBanner];
if(!localBannerAdded){
CGSize size = [[CCDirector sharedDirector] winSize];
localBannerButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
localBannerButton.frame = CGRectMake(0.0, 0.0, 320.0, 50.0);
[localBannerButton setTitle:@"DOWNLOAD MORE FREE GAMES" forState:UIControlStateNormal];
localBannerButton.backgroundColor = [UIColor whiteColor];//[UIColor clearColor];
[localBannerButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal ];
[self.view addSubview:localBannerButton];
[localBannerButton setCenter:CGPointMake(self.view.center.x,(size.height-CGRectGetHeight(localBannerButton.frame)/2)-2)];
// Add Target-Action Pair
[localBannerButton addTarget:self action:@selector(openAppStore:) forControlEvents:UIControlEventTouchUpInside];
localBannerAdded = YES;
}
}发布于 2017-03-25 15:52:18
我今天才遇到这个错误,对我来说问题很简单,因为adUnitID基本上还是个新版本。在创建adUnitID后,我不得不等待2个多小时才能收到广告。
如果你有这个错误,你的一些adUnitIDs提供广告,有些没有,你很可能遇到同样的问题,修复它的唯一方法就是等待。
发布于 2016-08-24 03:10:31
广告服务器将返回此消息的主要原因如下:
或者查看下面的链接,它可能会对您有所帮助
https://groups.google.com/forum/#!topic/google-admob-ads-sdk/ioXU2nX9W28
发布于 2017-06-20 07:14:05
我刚刚创建了一个新帐户,并看到了这个问题。在检查我的帐户时,在admob页面顶部显示了一条消息:“您的广告单元没有显示广告,因为您还没有提供您的帐户支付信息。”点击Fix it按钮,填写表格,广告将在几个小时内显示
https://stackoverflow.com/questions/39108558
复制相似问题