簡體   English   中英

Google Admob橫幅廣告未加載AnchorType.top

[英]Google Admob banner ads not loading with AnchorType.top

我有一個我在Android商店發布的Flutter應用程序。 一切都功能齊全,包括橫幅廣告。 我現在正在嘗試讓應用程序的蘋果方面正常工作,並且一直在熨平阻礙這個過程的無數蘋果漏洞。

此時我無法解決的是橫幅廣告。 它們根本沒有出現在iphone上。 我已按照此官方指南中的所有內容進行操作: https//developers.google.com/ad-manager/mobile-ads-sdk/ios/quick-start

我已將Info.plist中的GADApplicationIdentifier設置為Admob中我應用的應用ID。

我在Info.plist中添加了GADIsAdManagerApp並將其設置為YES。

我在Info.plist中添加了io.flutter.embedded_views_preview並將其設置為YES。

我從門戶網站下載了一個最新的,新鮮的GoogleService-info.plist文件,並將其添加到我的應用程序的runner文件夾中,但即使經過所有這些步驟,我得到:

蘋果錯誤

沒有任何其他信息可以提供有關失敗原因的任何線索。

我的橫幅代碼(在Android中正常工作):

  @override
  void initState() {
    FirebaseAdMob.instance.initialize(appId: 'ca-app-pub-XXXXXXXXXX~XXXXXX');
    _loadBannerState();
    super.initState();
  }

  _loadBannerState() async {
      myBanner
        ..load()
        ..show(
          anchorOffset: 0.0,
          anchorType: AnchorType.top,
        );
    }
  }

  static MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
    keywords: <String>['flutterio', 'beautiful apps'],
    contentUrl: 'https://flutter.io',
    childDirected: false,
    designedForFamilies: true,
    gender: MobileAdGender.unknown,
    testDevices: <String>["XXXXXXXXXXXXXXXXXX"], // Android phone
  );

  BannerAd myBanner = BannerAd(
    adUnitId: 'ca-app-pub-XXXXXXXXX/XXXXXXXXXX', //Banner_OnePlayer
    size: AdSize.banner,
    targetingInfo: targetingInfo,
    listener: (MobileAdEvent event) {
      print("BannerAd event is $event");
    },
  );

有沒有人在IOS中使用Admob橫幅廣告?


編輯:

所以我找到了錯誤的原因,但沒有找到解決方案。 整個問題是由這一行造成的:

anchorType: AnchorType.top,

使用此設置,廣告將無法在IOS上加載。 如果我將其設置為底部,廣告加載完全正常。 似乎是另一個可怕的IOS錯誤,但我不知道如何解決這個問題,請記住我需要在屏幕頂部顯示橫幅。

有沒有另一種方法來實現這種定位而不使用anchortype?

截圖:

在此輸入圖像描述

如果您使用的是AnchorType.top嘗試以下操作:

myBanner
  ..load()
  ..show(
    anchorOffset: kToolbarHeight + 50, // 50 is the height of the banner ad
    anchorType: AnchorType.top, // it should work now because we have added offset
);

如果您使用的是AnchorType.bottom嘗試以下操作:

myBanner
  ..load()
  ..show(
    // it makes sure we are right below the AppBar, 50 is the height of Banner ad
    anchorOffset: queryData.size.height - kToolbarHeight - 50 - queryData.padding.top - queryData.padding.bottom,
    anchorType: AnchorType.bottom,
);

經過測試(包括肖像和風景)

  • iPhone XS模擬器
  • iPhone 6s真實設備

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM