【问题标题】:AdMob interstitial error "Request Error: No ad to show"AdMob 插页式错误“请求错误:没有广告可展示”
【发布时间】:2020-11-02 10:43:51
【问题描述】:

我正在使用 Swift2 和 Xcode7 开发一个 iOS 应用程序。我正在尝试实施 AdMob,但它不显示我的插页式广告。

override func viewDidLoad() {
    super.viewDidLoad()

    _interstitial = createAndLoadInterstitial()
}

func createAndLoadInterstitial()->GADInterstitial {
    let interstitial = GADInterstitial(adUnitID: "interstitial_ID")
    let gadRequest:GADRequest = GADRequest()
    gadRequest.testDevices = ["test device id"]
    interstitial.delegate = self
    interstitial?.loadRequest(gadRequest)

    return interstitial!
}

func interstitialDidReceiveAd(ad: GADInterstitial!) {
    _interstitial?.presentFromRootViewController(self)
}

func interstitial(ad: GADInterstitial!, didFailToReceiveAdWithError error: GADRequestError!) {
    print(error.localizedDescription)
}

func interstitialDidDismissScreen(ad: GADInterstitial!) {
    _interstitial = createAndLoadInterstitial()
}

我收到此错误:

请求错误:没有广告可展示。

【问题讨论】:

  • 请求错误:没有可展示的广告,听起来 AdMob 无法满足您的广告请求。再试一次。您是否收到任何其他错误/警告?您使用的是哪个版本的 AdMob SDK?
  • @DanielStorm 我用 CocoaPods(pod 'Google-Mobile-Ads-SDK', '~> 7.0') 安装了 AdMob。我又试了一次,但只收到了那个错误。
  • 但是 GADBannerView 正常显示...

标签: ios swift admob


【解决方案1】:

Request Error: No ad to show.

表示您的请求已成功,但 Admob 目前没有可在您的设备上展示的广告。确保您始终有广告展示的最佳方法是使用中介,以便将未完成的请求传递到另一个广告网络。 Admob 提供了很好的机制来做到这一点。

【讨论】:

  • 感谢您的回复。我从来没想过。我会尽快实现这个功能!
  • 什么是“中介”,它是如何实现的?
  • 中介是您将广告客户端配置为展示来自多个广告网络的广告的地方。大多数广告客户端(如 Admob)通过保持客户端上的配置相同并允许您通过其网络应用程序配置广告网络列表来简化此操作。
  • 好主意,您可以将 AppLovin、InMobi、Tapjoy、Leadbolt 与 AdMob 或不同的提供商结合使用
【解决方案2】:

您应该有两个广告单元 ID。一份给你的GADBannerView,一份给你的GADInterstitial。确保 AdMob 为您的插页式广告提供的广告单元 ID 完全与他们提供的相同。更新到latest AdMob SDK,当前为 7.5.0。还可以考虑在特定时间间隔或在用户完成所需操作后调用presentFromRootViewController(self)。您现在的设置方式将继续展示一个又一个的插页式广告,因为每次关闭一个插页式广告时您都会发送对新插页式广告的请求,然后在收到广告后立即显示该插页式广告。

import UIKit
import GoogleMobileAds

class ViewController: UIViewController, GADInterstitialDelegate {

    var myInterstitial : GADInterstitial?

    override func viewDidLoad() {
        super.viewDidLoad()
        myInterstitial = createAndLoadInterstitial()
    }

    func createAndLoadInterstitial()->GADInterstitial {
        let interstitial = GADInterstitial(adUnitID: "Your Ad Unit ID")
        interstitial.delegate = self
        interstitial?.loadRequest(GADRequest())
        return interstitial
    }

    @IBAction func someButton(sender: AnyObject) {
        myInterstitial?.presentFromRootViewController(self)
    }

    func interstitialDidReceiveAd(ad: GADInterstitial!) {
        print("interstitialDidReceiveAd")
    }

    func interstitial(ad: GADInterstitial!, didFailToReceiveAdWithError error: GADRequestError!) {
        print(error.localizedDescription)
    }

    func interstitialDidDismissScreen(ad: GADInterstitial!) {
        print("interstitialDidDismissScreen")
        myInterstitial = createAndLoadInterstitial()
    }

【讨论】:

  • 感谢您的重播。但是我已经有两个广告单元 ID,分别是 GADBannerViewGADInterstitial
  • @MitsuhikoShimomura 检查以确保您的插页式广告单元 ID 与 AdMob 提供给您的完全相同。使用不存在/输入错误的广告单元 ID 将导致 Request Error: No ads to show 错误。
  • 我的 AdMob 控制台 (i.stack.imgur.com/mMVQH.png)。我从那里复制了 Unit ID,所以我确定没有错。
  • 我注意到GAdMob直到一定时间才会为新会员提供广告,为什么我不知道?您可以从您的代码中确定将您的广告 ID 替换为 GADTestID 之一,并且我确信它会 100% 收到广告,因为我对其进行了 10 多次测试并且它有效。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-02
  • 1970-01-01
  • 2016-12-30
  • 2016-10-16
  • 1970-01-01
  • 2018-04-06
相关资源
最近更新 更多