Google Admob实时广告未在真实设备上的iOS 11中展示 [英] Google Admob live ads not showing in iOS 11 on real device

查看:91
本文介绍了Google Admob实时广告未在真实设备上的iOS 11中展示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在网上和StackOverflow上搜索并找到了与我有相同或相似错误消息的帖子,但没有一个与我有相同的错误。它们具有不同的条件,即错误消息出现在不同的情况下,或者它们位于不同版本的iOS等上。我已经尝试了在网上找到的所有解决方案。

I have searched and found posts online and on StackOverflow which have the same or similar error message as me, but none of them are having the same bug as me. They have different conditions i.e. the error message appears in different situations or they are on a different version of iOS etc. I’ve tried all the solutions i’ve found online.

基本上,我正在使用Admob在我的iOS应用中显示横幅广告和插页式广告。这些已在实时应用程序中运行了一年以上,它们目前仍在iOS 10设备和iOS的早期版本中实时运行,没有任何问题。

Basically I am using Admob to show banner ads and interstitial ads in my iOS app. These have been running in the live app for over a year, they are still currently running live in iOS 10 devices and earlier versions of iOS, without any problems .

但是当iOS已更新为iOS11,情况已更改。

But when iOS updated to iOS11, things changed.

测试广告可在所有iOS版本的模拟器和实际设备上运行。实时广告可在所有iOS版本的模拟器上运行。实时广告可在iOS 10实际设备上运行,但不能在iOS 11实际设备(iOS 11上的iPhone SE)上运行。从商店下载的实时应用程序也是如此。

Test ads work on the simulator and actual devices on all versions of iOS. The live ads work on the simulator on all versions of iOS. Live ads work on an iOS 10 actual device but they do not work on an iOS 11 actual device(iPhone SE on iOS 11). This is also the case for the live app downloaded from the store.

这必须归因于iOS 11中的新功能。

It must be due to something new in iOS 11.

我收到以下横幅广告和插页式广告的错误消息:

I get the error message below for the banner ad and interstitial ad:

adView:didFailToReceiveAdWithError:请求错误:无广告显示。

"adView:didFailToReceiveAdWithError: Request Error: No ad to show."

我将在下面显示我的代码。

I’ll show my code below.

我也尝试过重新安装该应用程序。尝试更新AdWords帐户中的结算信息,并检查了限制广告跟踪功能是否已禁用。由于iOS 11停用,我也尝试更新广告的实施方式。仍然无法使用。目前使用的是最新版本的SDK,Google Mobile Ads SDK版本:afma-sdk-i-v7.26.0。

I've also tried reinstalling the app. I’ve tried updating my billing information in my AdWords account and I’ve checked that Limit Ad Tracking is disabled. I've also tried updating my implementation of the ads now that iOS 11 is out. Still doesn't work. Currently using the latest version of the SDK, Google Mobile Ads SDK version: afma-sdk-i-v7.26.0.

这是我的原始代码,仍在iOS 10的实时应用程序中运行设备没有任何问题。

Here is my original code thats still running in the live app on iOS 10 devices without any problems.

-(void)implementGoogleBannerAds
{
    self.googleBannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];  
    self.googleBannerView.adUnitID = @"ca-app-pub-4170137185945186/3406302758";
    self.googleBannerView.rootViewController = self;
    self.googleBannerView.delegate = self;

    // Place the ad view onto the screen.
    [self.view addSubview:self.googleBannerView]; 
    [self.googleBannerView loadRequest:[GADRequest request]];
    self.googleBannerView.hidden=NO;

}

我尝试将其更新为Admob刚刚在他们的代码中更新过的代码iOS11入门笔记,但这没有任何改变。它仍然可以在模拟器和iOS10真实设备上运行,但不能在真实的iOS 11设备上运行。

I tried updating this to the code Admob just updated in their Get Started notes for iOS11 but this didn't change anything. It still works in the simulator and on iOS10 real devices but not a real iOS 11 device.

-(void)implementGoogleBannerAds
{
   self.googleBannerView = [[GADBannerView alloc]
                       initWithAdSize:kGADAdSizeSmartBannerPortrait];

    self.googleBannerView.adUnitID = @"ca-app-pub-4170137185945186/3406302758";
    self.googleBannerView.rootViewController = self;
    [self.googleBannerView loadRequest:[GADRequest request]];
    self.googleBannerView.delegate = self;

}

-(void)adViewDidReceiveAd:(GADBannerView *)adView {
    NSLog(@"adViewDidReceiveAd");

    self.googleBannerView.hidden=NO;
    [self addBannerViewToView:self.googleBannerView];
}

-(void)addBannerViewToView:(UIView *)bannerView {
      NSLog(@"addBannerViewToView");
    bannerView.translatesAutoresizingMaskIntoConstraints = NO;
    [self.view addSubview:bannerView];
    if (@available(ios 11.0, *)) {
        // In iOS 11, we need to constrain the view to the safe area.
        [self positionBannerViewFullWidthAtBottomOfSafeArea:bannerView];
    } else {
        // In lower iOS versions, safe area is not available so we use
        // bottom layout guide and view edges.
        [self positionBannerViewFullWidthAtBottomOfView:bannerView];
    }
}

-(void)positionBannerViewFullWidthAtBottomOfSafeArea:(UIView *_Nonnull)bannerView NS_AVAILABLE_IOS(11.0) {
    // Position the banner. Stick it to the bottom of the Safe Area.
    // Make it constrained to the edges of the safe area.
    UILayoutGuide *guide = self.view.safeAreaLayoutGuide;
        [NSLayoutConstraint activateConstraints:@[
                                                  [guide.leftAnchor constraintEqualToAnchor:bannerView.leftAnchor],
                                                  [guide.rightAnchor constraintEqualToAnchor:bannerView.rightAnchor],
                                                  [guide.bottomAnchor constraintEqualToAnchor:bannerView.bottomAnchor]
                                                  ]];

}

-(void)positionBannerViewFullWidthAtBottomOfView:(UIView *_Nonnull)bannerView {
        [self.view addConstraint:[NSLayoutConstraint constraintWithItem:bannerView
                                                              attribute:NSLayoutAttributeLeading
                                                              relatedBy:NSLayoutRelationEqual
                                                                 toItem:self.view
                                                              attribute:NSLayoutAttributeLeading
                                                             multiplier:1
                                                               constant:0]];
        [self.view addConstraint:[NSLayoutConstraint constraintWithItem:bannerView
                                                              attribute:NSLayoutAttributeTrailing
                                                              relatedBy:NSLayoutRelationEqual
                                                                 toItem:self.view
                                                              attribute:NSLayoutAttributeTrailing
                                                             multiplier:1
                                                               constant:0]];
        [self.view addConstraint:[NSLayoutConstraint constraintWithItem:bannerView
                                                              attribute:NSLayoutAttributeBottom
                                                              relatedBy:NSLayoutRelationEqual
                                                                 toItem:self.bottomLayoutGuide
                                                              attribute:NSLayoutAttributeTop
                                                             multiplier:1
                                                               constant:0]];
}


推荐答案

我遇到了同样的问题最新的 cordova-plugin-admob-pro 2.30.1 AdMob iOS SDK 7.27.0 。将我的设备更新到iOS 11.2.2后,此问题已解决,并且SMART_BANNER大小的横幅广告和插页式广告始终显示。

I had the same problem with the latest cordova-plugin-admob-pro 2.30.1 with AdMob iOS SDK 7.27.0 on my iPhone 7 when on iOS 11.1.2. After updating my device to iOS 11.2.2 the problem has been solved and SMART_BANNER size Banner and Interstitial ads display consistently.

这篇关于Google Admob实时广告未在真实设备上的iOS 11中展示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆