Admob使用Admob SDK版本6.12.0在Xamarin iOS应用上发布问题

时间:2014-12-10 12:20:33

标签: xamarin.ios ios8 xamarin admob google-dfp

我目前正在使用Google AdMob Xamarin组件(版本6.12.0 - 请参阅https://components.xamarin.com/view/googleadmob)在iOS应用上显示DFP插页式广告和横幅广告(显示在桌面视图中的不同位置)。当我在Visual Studio 2013中进行调试时,我得到以下输出:

<Google:HTML> You are currently using version 6.12.0 of the SDK, which doesn't
officially support iOS 8. Please consider updating your SDK to the most recent
sdk version, 6.12.2, to get iOS 8 support, including a fix for smart banner
rendering in landscape mode. The latest SDK can be downloaded from 
http://goo.gl/iGzfsP. A full list of release notes is available at
https://developers.google.com/mobile-ads-sdk/docs/admob/ios/rel-notes.

根据Xamarin组件的页面,6.12.0确实支持iOS 8.我应该忽略我收到的警告吗?如果没有,当组件的最新版本仅为6.12.0时,如何使用6.12.2?可以继续使用6.12.0还是会导致问题?

我注意到横幅广告并没有真正显示在iOS8上的正确位置,它们位于右侧和下方。这是因为SDK还是关于如何显示单元格的iOS8中的其他一些变化?

以下是我展示横幅广告的方式:

public void InitialiseBanner(AdMobView property)
  {
        _bannerViewDelegate = new AdMobBannerViewDelegate();

        _bannerView = new DFPBannerView();


        float x = (CurrentWidth/2) - (AdvertWidth/2);

        _bannerView.RootViewController = this;
        _bannerView.BackgroundColor = UIColor.White;
        _bannerView.Delegate = _bannerViewDelegate;
        _bannerView.Frame = new RectangleF(x, 5, AdvertWidth, 50);

        View.Frame = new RectangleF(0, 0, CurrentWidth, 50);
        View.AddSubview(_bannerView);
        _bannerView.AdUnitID = "/**UNITIDREMOVED**/" + property.AdAlias;
        GADRequest request = GADRequest.Request;

        .
        .
        .

        _bannerView.LoadRequest(request);

        View.BringSubviewToFront(_bannerView);

        if (DeviceHelper.IsIos8OrGreater && RespondsToSelector(new Selector("separatorInset")))
        {
            _bannerView.LayoutMargins = UIEdgeInsets.Zero;
        }


    }

1 个答案:

答案 0 :(得分:0)

对于普通横幅,请尝试加载您的AdView,如下所示: (这是我的工作示例)

作为班级声明,请输入以下内容:

    GADBannerView adView;
    bool viewOnScreen = false;

    // Get you own AdmobId from: http://www.google.com/ads/admob/
    const string AdmobId = "<your admob id>";

然后在viewDidLoad中,您可以指定横幅的位置并加载它:

            adView = new GADBannerView (size: GADAdSizeCons.Banner, origin: new PointF (0, UIScreen.MainScreen.Bounds.Height-100)) {
            AdUnitID = AdmobId,
            RootViewController = this
        };

        adView.DidReceiveAd += (sender, args) => {
            if (!viewOnScreen) View.AddSubview (adView);
            viewOnScreen = true;
        };

        adView.LoadRequest (GADRequest.Request);

我也得到同样的错误,但实际上并不重要。我还首先想到这是问题,但我的设置有点不对,我认为你的代码是一样的。在我的示例中,我刚将AdView添加到MainView,但使用自定义单元格,您应该能够在UITable视图中实现它。另外,请查看组件部分中提供的示例。至于显示DFP插页式广告:设置也有问题,但我无法在您提供的代码中看到它。