IMAAdsLoader 在 Swift 中出错,但在 Objective C 中出错

IMAAdsLoader Erroring in Swift but not Objective C

我在 tvOS 中使用 GoolgeInteractiveMediaAds 框架。在该过程的最开始,我从委托中收到一条错误消息:Error loading ads: nil。我还加载了用 Objective C 编写的示例 Google 项目,其中 运行 没有错误。这个阶段的代码非常少,我比较了这两个项目,发现 AppDelegateInfo.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 设置差异会导致这种情况?

来自 Google 的 IMA SDK 团队:

At the moment, I'm afraid we cannot give you support on this as our documentation and the sample app are on the Obj-c version only. A feature request has been made for the IMA SDK for tvOS Swift version. However, I cannot give a definite date on when this will be available.

因此,在可预见的将来,我们可能会在 Objective C 中对这部分进行编码。

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

I already raised this to the rest of the team. As per discussion, this seems to be a bug on our SDK side and this has already been relayed to our Engineering team for further investigation. I'll update this thread for any feedback available

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

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

2019 年 7 月 31 日更新:

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

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

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

长话短说:

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