Admob测试广告和真实广告均未展示

时间:2020-04-29 07:38:58

标签: swift admob

我的应用程序在模拟器和真实设备上都没有收到来自Admob的测试广告或真实广告。但是,如果我更改了应用程序的捆绑软件ID,它将收到两种类型的广告。我将应用切换到新的AdMob帐户后,出现了问题。我已经更新了Info.plist文件中的发布者ID,还更新了新帐户所使用的广告单元。

收到的错误是:

Error Domain=com.google.admob Code=1 "Request Error: No ad to show." UserInfo={NSLocalizedDescription=Request Error: No ad to show.}

我已经在以下位置实施了Admob以下指南

https://developers.google.com/admob/ios/quick-start

https://developers.google.com/admob/ios/banner

var bannerView: GADBannerView!

override func viewDidLoad() {
    ...

    bannerView = GADBannerView(adSize: kGADAdSizeBanner)

    bannerView.adUnitID = "ca-app-pub-3940256099942544/2934735716"
    bannerView.rootViewController = self

    bannerView.delegate = self

    bannerView.load(GADRequest())

    addBannerViewToView(bannerView)
}

func addBannerViewToView(_ bannerView: GADBannerView) {
    bannerView.translatesAutoresizingMaskIntoConstraints = false
    view.addSubview(bannerView)
    view.addConstraints(
      [NSLayoutConstraint(item: bannerView,
                          attribute: .bottom,
                          relatedBy: .equal,
                          toItem: bottomLayoutGuide,
                          attribute: .top,
                          multiplier: 1,
                          constant: 0),
       NSLayoutConstraint(item: bannerView,
                          attribute: .centerX,
                          relatedBy: .equal,
                          toItem: view,
                          attribute: .centerX,
                          multiplier: 1,
                          constant: 0)
      ])
   }
...

func adView(_ bannerView: GADBannerView,
    didFailToReceiveAdWithError error: GADRequestError) {

    print(error)
}

0 个答案:

没有答案