Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Admob bannerView请求错误:没有要显示的广告_Ios_Objective C_Cocos2d Iphone_Admob - Fatal编程技术网

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

Ios Admob bannerView请求错误:没有要显示的广告,ios,objective-c,cocos2d-iphone,admob,Ios,Objective C,Cocos2d Iphone,Admob,我在一个ios游戏的广告上看到了这个问题 这是我的代码,奇怪的是,如果我在request.testDevices列表中添加设备,它会显示演示横幅,如果我从testDevices中删除,它不会显示真正的横幅,但是如果我在XCODE上更改bundleIdentifier,它会显示真正的横幅,所以我相信它与我的admob帐户有关,有人得到过类似的东西吗 它总是会因以下错误而失败: AdView didFailToReceiveAdWithError---------------------------

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

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

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

AdView didFailToReceiveAdWithError----------------------------------------错误域=com.google.ads代码=1“请求错误:没有要显示的广告。”用户信息={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;
    }
 }

广告服务器将返回此消息,主要是因为您的广告单元id没有广告。请检查您的广告单元id是否正确。如果横幅宽度/高度为0,则会出现相同的错误。确保你的奉承是完美的。 或 查看以下链接,它可能会对您有所帮助


我也遇到了这个错误。由于这个错误,我的横幅广告和插页广告都失败了。我发现全局更改UserAgent是我的错误,在我将UserAgent更改为默认值后,它工作得很好。

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


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

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

这解决了我的问题

  • 将横幅id更改为示例id
  • 然后运行应用程序
  • 将id更改回生产id

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

    一旦我设置好了,错误就消失了,广告也立即开始显示


    希望这对别人有帮助

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

    谷歌测试AdMobID: ca-app-pub-3940256099942544~1458002511

    谷歌测试横幅
    ca-app-pub-3940256099942544/2934735716

    确保在调试会话中使用测试ad ID

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


    如果您尚未在AdMob帐户中设置付款和账单信息,则可能发生此错误。 根据Admob,设置付款详细信息后,可能需要2小时才能完全正常工作


    确保不要使用GadbanerView的其他变量。在每个控制器中使用一个变量,使其成为全局变量,只需更改单元id即可

    e、 g该线路应在任何控制器(全局)之外

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

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

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

    adBannerView=GADBannerView()

    而且它起作用了

    我不能确切地说是哪个AdMob库版本,但突然,横幅不再显示了

    使用大小作为参数初始化横幅,修复了以下问题:


    adBannerView=GADBannerView(adSize:kGADAdSizeBanner)
    一个可能的原因是约束缺陷

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


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

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

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

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


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

    在创建
    adUnitID
    后,等待1-2小时,然后尝试

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


    享受编码:)

    我认为最好的方式应该是使用谷歌集成指南中的测试广告ID,在它上线后更改为你的广告ID。

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

    我不认为我被列入黑名单,我已经查看了我的adsense帐户,但在状态中没有看到任何内容。我发了一条信息,以便他们可以检查其黑名单,还没有回应。我尝试了这两种方法,但都不走运,我想我必须等待admob的某个人查看我的帐户,而且我确定如果我更改了捆绑标识,它的大小不会正常工作,而且它也不会显示不同的捆绑。设置横幅宽度/高度为我解决了这一问题。非常有帮助!我的横幅与目标距离为1像素
    bannerView.adUnitID = "ca-app-exampleid-abcabc938-4e8"