Admob bannerView请求错误:无广告显示

Gil*_*uth 23 objective-c cocos2d-iphone admob ios

我在我的一个ios游戏广告中遇到此问题

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

它总是失败了这个错误:

AdView didFailToReceiveAdWithError ---------------------------:Error Domain = com.google.ads Code = 1"请求错误:无广告显示. " UserInfo = {NSLocalizedDescription =请求错误:无广告显示.,NSLocalizedFailureReason =请求错误:无广告显示.}

在我的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... */

}
Run Code Online (Sandbox Code Playgroud)

在我的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;
    }
 }
Run Code Online (Sandbox Code Playgroud)

Ibr*_*him 16

我今天刚刚遇到这个错误,对我来说问题很简单,那是因为adUnitID它基本上还是新的.创建adUnitID广告后,我必须等待超过2小时才能投放广告.

如果您有此错误,您的某些adUnitIDs服务广告和部分广告都没有.你极有可能遇到同样的问题,解决问题的唯一方法就是等待.

  • 从两周前开始,我已经等了两个小时了:)。这对我不起作用。 (6认同)

San*_*kar 12

广告服务器将返回此邮件主要是因为您的广告单元ID没有广告.检查您的广告单元ID是否正确.如果您的横幅宽度/高度为0,您将得到相同的错误.确保您的adUnitID是完美的.或查看以下链接,它可以帮助您 https://groups.google.com/forum/#!topic/google-admob-ads-sdk/ioXU2nX9W28

AdMob旧版发布商ID未显示广告

  • 设置横幅宽度/高度为我修复了它.非常有帮助! (5认同)

Ton*_*ony 9

我刚刚创建了一个新帐户并看到了这个问题.在查看我的帐户时,admob页面顶部显示一条消息:"您的广告单元未显示广告,因为您尚未提供帐户付款信息." 点击按钮修复它,填写表格,广告将在几个小时内显示


Ric*_*tos 6

确保您在调试会话中使用测试广告 ID。

https://developers.google.com/admob/ios/banner?hl=en-US

加载测试广告的最简单方法是使用我们针对 iOS 横幅的专用测试广告单元 ID:ca-app-pub-3940256099942544/2934735716


小智 5

我也遇到了这个错误。我的横幅广告和插页式广告均因此错误而失败。我发现全局更改 UserAgent 是我的错误,将 UserAgent 更改为默认值后效果很好。