admob 测试广告 -> 没有广告显示

admob TEST ad -> No ad to show

这不是重复的..

在新的 Admob SDK (Google-Mobile-Ads-SDK 7.31.0) 中,当您展示测试广告时,它会向您展示 真实广告(!),它添加了一个注释 "Test Ad"

但有时,当您确实需要展示广告时(出于测试目的)- 您会收到错误代码 1 "Request Error: No ad to show."

一个测试广告。测试显示的时候能看到"Test Ad"字样! (显示时,现在什么都没有显示 =[)

所以,我的问题是: 有人知道解决方法吗?

现在我知道答案了...这是 SDK 中的一个错误。 =[

see here

The easiest way to load test ads is to use our dedicated test ad unit ID for iOS banners: ca-app-pub-3940256099942544/2934735716

It's been specially configured to return test ads for every request, and you're free to use it in your own apps while coding, testing, and debugging. Just make sure you replace it with your own ad unit ID before publishing your app.


编辑:我发现并解决了真正的问题。

制作广告时,您有两种选择:

  1. 将其添加到视图层次结构它加载广告之后---> 始终有效
  2. 将它添加到视图层次结构它加载广告之前---> 小心这个

如果您选择第二种方法,则必须将广告视图的框架设置为可见尺寸(宽度 + 高度)并且您必须确保 isHidden = false

我的问题是我想为广告的展示设置动画。我将横幅添加到 UIStackView 并将其 isHidden 设置为 true

我使用了委托,因此在加载广告时我将 isHidden 动画化为 false。一切看起来都不错,但显然 Google 移动广告 SDK 在加载广告之前会验证广告是否可见 --- 我的广告视图 可见!所以我得到了 Request Error: No ad to show

Thanks Google for "great" documentation =[