1

GoolgeInteractiveMediaAds在 tvOS 中使用该框架。在这个过程的最开始,我从代表那里得到一个错误,上面写着:Error loading ads: nil. 我还加载了用 Objective C 编写的示例 Google 项目,该项目运行没有错误。在这个阶段几乎没有代码,我比较了这两个项目,并没有发现在AppDelegateand方面有任何区别Info.plist(唯一的区别是 Swift 项目从故事板开始)。

以下是代码的总和。当运行setUpAdsLoader立即遇到您在底部看到的错误委托时。将他们的示例 Objective C 项目缩减为这些行,不会产生此错误。

import UIKit
import GoogleInteractiveMediaAds

class ViewController: UIViewController, IMAAdsLoaderDelegate {

private var adsLoader: IMAAdsLoader?

override func viewDidLoad() {
    super.viewDidLoad()

    setUpAdsLoader()
}

func setUpAdsLoader() {
    self.adsLoader = IMAAdsLoader(settings: nil)
    self.adsLoader!.delegate = self
}

func adsLoader(_ loader: IMAAdsLoader!, adsLoadedWith adsLoadedData: IMAAdsLoadedData!) {
    // Grab the instance of the IMAAdsManager and set ourselves as the delegate
    //adsManager = adsLoadedData.adsManager
    //adsManager!.delegate = self

    // Create ads rendering settings and tell the SDK to use the in-app browser.
    let adsRenderingSettings = IMAAdsRenderingSettings()
    adsRenderingSettings.webOpenerPresentingController = self

    // Initialize the ads manager.
    //adsManager!.initialize(with: adsRenderingSettings)
}

func adsLoader(_ loader: IMAAdsLoader!, failedWith adErrorData: IMAAdLoadingErrorData!) {
    print("Error loading ads: \(String(describing: adErrorData.adError.message))")
}
}

更新:我创建了相同的测试项目,但这次使用的是 Objective C。工作没有错误。很难相信问题出在语言上,但我想知道这两种语言之间是否存在任何 Xcode 设置差异会导致这种情况?

4

2 回答 2

1

我今天在这个问题上苦苦挣扎,我发现我在这里描述的:

https://github.com/googleads/googleads-ima-tvos-client-side/issues/4

TL;博士:

如果可能,将tvos短语添加到您的捆绑包 ID。

于 2019-07-25T15:48:58.187 回答
-1

来自 Google 的 IMA SDK 团队:

目前,恐怕我们无法为您提供支持,因为我们的文档和示例应用程序仅在 Obj-c 版本上。已针对 tvOS Swift 版本的 IMA SDK 提出功能请求。但是,我无法给出何时可用的确切日期。

因此,在可预见的未来,我们可能会被困在 Objective C 中编写这部分代码。

IMA 团队的更新现在表明这实际上是他们的 SDK 中的一个错误。

我已经向团队的其他成员提出了这个问题。根据讨论,这似乎是我们 SDK 方面的一个错误,并且已经转发给我们的工程团队进行进一步调查。我将更新此线程以获取任何可用的反馈

作为更新,我的同事发现将“tvos”添加到 bundleID 解决了这个问题。谷歌已经确定了他们这边的问题,并且也在修复。详细信息可以在这里找到:

https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/ima-sdk/YfJrVhFLuWI/cZ2VJS84BwAJ

2019 年 7 月 31 日更新:

谷歌表示他们已在最新的 tvOS SDK 中发布了针对此问题的修复程序。

于 2019-07-08T18:06:06.873 回答