【问题标题】:Admob bannerView Request Error: No ad to showAdmob 横幅视图请求错误:没有广告可显示
【发布时间】:2016-12-30 17:14:14
【问题描述】:

我的一个 ios 游戏广告遇到了这个问题

这是我的代码,奇怪的是,如果我在 request.testDevices 列表中添加设备,它会显示演示横幅,如果我从 testDevices 中删除,它不会显示真正的横幅,但如果我更改我的 bundleIdentifier在 XCODE 上,它显示了一个真实的横幅,所以我相信它与我的 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... */

}

在我的 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;
    }
 }

【问题讨论】:

  • 我的横幅距离游戏区域有 1 个像素的距离,因此将横幅从游戏屏幕上移除,并要求重新评估,为我修复。可悲的是花了将近 3 个月的时间才从 Admob 得到问题的答案,我从来没有收到一封电子邮件告诉它,也没有任何其他来自 admob 的联系方式。修复速度很快,Apple 批准了我的游戏的新版本后,12 小时后我的横幅又回来了。
  • 差不多两年后,我仍然遇到同样的问题。真的是我切换到另一个广告平台的时候了。
  • 在模拟器/设备上新安装应用程序时工作。

标签: ios objective-c cocos2d-iphone admob


【解决方案1】:

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

如果您遇到此错误,并且您的某些 adUnitIDs 会投放广告,而有些则不会。您很有可能遇到同样的问题,解决它的唯一方法就是等待。

【讨论】:

  • 我刚刚集成了 AdMob for ios 移动应用程序。获取应用 ID 并在 appdelegate 中添加 configureWithApplicationID 并在视图控制器中添加 initWithAdUnitID request.testDevices = @[ @"some id"];这里 request.testdevices 不是必需的吗?看完你的回答后,我会等待尝试等待 2 小时。
  • 有后续吗?您在 2 小时后尝试了吗
  • 自 2 周前以来,我正在等待 2 小时过去 :)。这对我不起作用。
【解决方案2】:

广告服务器会返回此消息主要是因为以下原因:

  • 您的广告单元 ID 没有广告。
  • 检查您的广告单元 ID 是否正确。
  • 如果您的横幅宽度/高度为 0,您将收到相同的错误。
  • 确保您的 adUnitID 完美无缺。

或 检查以下链接可能对您有所帮助

https://groups.google.com/forum/#!topic/google-admob-ads-sdk/ioXU2nX9W28

AdMob Legacy Publisher ID not showing ads

【讨论】:

  • 我不相信我被列入黑名单,我查看了我的 adsense 帐户,但在状态上看不到任何内容。我发了一条消息,这样他们就可以检查它的黑名单是否还没有回复。我两个都试过了,不走运,我想我将不得不等待,所以 admob 中的某个人会查看我的帐户,而且我确定如果我更改捆绑标识符,它的大小不会像它一样工作,并且确保它不是 adUnitID 为它还显示不同的捆绑包。
  • 设置横幅宽度/高度为我修复了它。非常有帮助!
  • 我的横幅距离游戏区域有 1 个像素的距离,因此将横幅从游戏屏幕上移除,并要求重新评估,为我修复。可悲的是花了将近 3 个月的时间才从 Admob 得到问题的答案,我从来没有收到一封电子邮件告诉它,也没有任何其他来自 admob 的联系方式。修复速度很快,Apple 批准了我的游戏的新版本后,我的横幅在 12 小时内又回来了。
  • 这为我解决了这个问题,我将横幅高度设置为 0,如果我收到广告,我将其设置为 50,但由于它是 0,因此代表总是无法获得广告。跨度>
  • @mrgrieves 您是否必须联系 google ad mobs 支持才能解决问题?我遇到了类似的问题,但我不确定该联系谁。
【解决方案3】:

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

【讨论】:

    【解决方案4】:

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

    【讨论】:

    • 如何更改 UserAgent?
    • 我在投放实时广告和测试广告时遇到了问题,事实证明这是因为我使用 [[NSUserDefaults standardUserDefaults] registerDefaults:@{@"UserAgent":@"MyUserAgent"}]; 在我的应用程序的默认 plist 中注册了一个“@UserAgent”键。删除此密钥并通过 NSURLSessionConfigurationWKWebViewConfiguration 手动设置 UserAgent 为我解决了这个问题。
    【解决方案5】:

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

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

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

    【讨论】:

      【解决方案6】:

      如果您没有在 AdMob 帐户中设置付款和结算信息,则可能会发生此错误。 根据 Admob 设置付款详细信息后,最多可能需要 2 小时才能完全正常运行

      Billing and Payments

      【讨论】:

        【解决方案7】:

        这解决了我的问题

        1. 将横幅 ID 更改为示例 ID。
        2. 然后运行应用程序。
        3. 将 id 改回生产 id。

        【讨论】:

          【解决方案8】:

          对我来说,它开始显示的原因是我没有在我的 AdMob 帐户上设置任何付款方式。

          设置完成后,错误消失了,广告立即开始展示。

          希望这对某人有所帮助!

          【讨论】:

          • 如果之前没有配置付款方式,那么这通常是问题的根源。
          • 设置帐户后,广告需要多长时间才能显示? @Dejan Atanasov?
          【解决方案9】:

          一个可能的原因是约束错误。

          你应该保证你的bannerView对其他视图的约束是 对了

          【讨论】:

            【解决方案10】:

            我在手机上测试示例应用程序时遇到了同样的问题。我修复了以下步骤:

            在 iPhone 6 上重置广告标识符,转到:

            设置 -> 隐私 -> 广告 -> 重置广告标识符

            【讨论】:

            • 我找不到“重置广告标识符”,请告诉我它在哪里。
            【解决方案11】:

            如果您在调试或测试模式下使用您的应用,请确保您使用的是由 google admob 提供的测试 AppID 和 BannerID,如下所示:-

            Google 测试 AdMobID: ca-app-pub-3940256099942544~1458002511

            Google 测试横幅 ID ca-app-pub-3940256099942544/2934735716

            【讨论】:

              【解决方案12】:

              创建adUnitID后,等待1-2小时再试用。

              因为我遇到了同样的问题,并且在 1-2 小时后就解决了。

              享受编码:)

              【讨论】:

                【解决方案13】:

                在我的情况下,广告工作正常,但突然停止显示广告并出现错误:没有广告可显示。 我注意到控制台抛出有关测试设备标识符的错误。不知何故,测试设备标识符被改变了。我不知道它是怎么发生的,可能是由于 Xcode 升级。我不知道。但是一旦我更改了测试设备标识符,它就会重新开始工作。

                【讨论】:

                  【解决方案14】:

                  确保不要创建 GADBannerView 的其他变量。在每个控制器中使用一个变量,使其成为全局变量,只需更改单元 ID。

                  例如,这条线应该在任何控制器之外(全局)

                  var bannerView: GADBannerView!
                  

                  然后在任何你想要的地方使用它并相应地更改 id

                  bannerView.adUnitID = "ca-app-exampleid-abcabc938-4e8"
                  

                  【讨论】:

                    【解决方案15】:

                    我习惯于这样初始化横幅:

                    adBannerView = GADBannerView()

                    它正在工作。

                    我无法准确说出来自哪个 AdMob 库版本,但突然间横幅不再显示了。

                    以尺寸为参数初始化banner,修复问题:

                    adBannerView = GADBannerView(adSize: kGADAdSizeBanner)

                    【讨论】:

                      【解决方案16】:

                      我通过在加载请求之前添加request.testDevice = @[@"xxxxxxxxxxxx"] 来解决这个问题。(我从控制台得到这个提示和测试设备号)

                      【讨论】:

                        【解决方案17】:

                        我认为最好的方法是使用 Google 集成指南中的测试广告 ID,然后在您的广告 ID 上线后更改。

                        【讨论】:

                          【解决方案18】:

                          在 iOS 设备的设置中:设置 > 隐私 > 广告:打开然后关闭“限制广告跟踪”(“重置广告标识符”并不总是有帮助。请先尝试“重置广告标识符”,然后如果此操作对您没有帮助,请发表评论)。 但!它只会帮助在您自己的设备上获取广告,并不能解决您的广告匹配率低的问题。

                          【讨论】:

                            猜你喜欢
                            • 1970-01-01
                            • 1970-01-01
                            • 1970-01-01
                            • 2014-02-02
                            • 1970-01-01
                            • 2021-11-04
                            • 1970-01-01
                            • 1970-01-01
                            • 2018-04-06
                            相关资源
                            最近更新 更多