gpt4 book ai didi

ios - swift & Admob : No ad to show

转载 作者:行者123 更新时间:2023-11-29 01:02:49 25 4
gpt4 key购买 nike

我正在尝试将 AdMob 添加到我的应用中。我的应用程序是用:UITabBarController 与 1. UIViewController; 2.UITableViewController; 3. 界面 View Controller ; 4. 界面 View Controller 。

我实际上是想在 3.UIViewController 中添加来自 Admob 的横幅广告。

我使用了那个代码:

@IBOutlet weak var amobBan: GADBannerView!
[•••]
amobBan.delegate = self
amobBan.adUnitID = "ca-app-pub-xxxxxxx" // I used mine in other apps : it works.
amobBan.rootViewController = self // NB: I also tried with tabBarController istead "self"
amobBan.loadRequest(GADRequest())

它不起作用:不显示广告。所以我使用了那个函数:

func adView(bannerView: GADBannerView!,
didFailToReceiveAdWithError error: GADRequestError!) {
print("adView:didFailToReceiveAdWithError: \(error.localizedDescription)")
}

我得到了这个输出:adView:didFailToReceiveAdWithError: 请求错误:没有要显示的广告。

我真的认为这是由于 amobBan.rootViewController = self> 造成的,因为当我设置 3 时显示广告。 UIViewController 作为 Storyboard 中的初始 ViewController。

我需要 Swift 的答案。

最佳答案

添加您的测试设备 - 真实设备和模拟器。您可能会在 Xcode 输出 Pane 中找到您的测试设备字符串。

let request: GADRequest = GADRequest()
request.testDevices = [ "661359a1bfeb6e588caf9c8133904d10", "96a6d0a80ffaa7094ad91b6648b6b50f", kGADSimulatorID ]
bannerView.load(request)

关于ios - swift & Admob : No ad to show,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36812369/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com