【问题标题】:IMAAdsLoader Erroring in Swift but not Objective CIMAAdsLoader 在 Swift 但不是 Objective C 中出错
【发布时间】:2019-07-07 19:18:40
【问题描述】:

我在 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 设置差异会导致这种情况?

【问题讨论】:

    标签: swift tvos google-ima


    【解决方案1】:

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

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

    TL;DR:

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

    【讨论】:

    • 大约一周前我在 IMA 组发帖,我的同事发现添加“tvos”可以解决问题。谷歌正在解决这个问题,详细信息可以在这里找到。我正在度假,否则我会更早发布。 groups.google.com/forum/…
    【解决方案2】:

    来自 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 日更新:

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

    【讨论】:

      猜你喜欢
      • 2015-08-08
      • 1970-01-01
      • 1970-01-01
      • 2020-02-04
      • 2015-03-30
      • 2014-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多