【问题标题】:GoogleCast iOS sender, v4, not sending messagesGoogleCast iOS 发件人,v4,不发送消息
【发布时间】:2018-07-17 04:54:46
【问题描述】:

在版本 2 中,发件人应用能够发送消息。

func deviceManager(_ deviceManager: GCKDeviceManager!,
didConnectToCastApplication
applicationMetadata: GCKApplicationMetadata!,
sessionID: String!,
launchedApplication: Bool) {
  deviceManager.add(self.textChannel)
}

但是,API 说我们现在使用的是 GCKSessionManager 而不是 GCKDeviceManager。

API 说我必须有一个 GCKSession 添加 textChannel,我在这里做了: 会话开始后,我添加 textChannel(因为 sessionManager.currentCastSession 在会话开始之前为 nil)。

func sessionManager(_ sessionManager: GCKSessionManager, didStart session: GCKSession) {
    if session.device == connectionQueue {
        connectionQueue = nil
    }
    self.sessionManager!.currentCastSession!.add(textChannel)
    print("")
}

同时,我在另一个函数中发送短信:

let result = self.textChannel.sendTextMessage("\(self.textField.text)", error: &error)

但结果总是假的,错误总是“Channel is not connected or is not registered with a session”。 此外,当我这样做时:

print("isConnected1 \(self.textChannel.isConnected)")

结果是假的。 你知道我还缺少哪些其他步骤来连接它吗?

【问题讨论】:

    标签: swift google-cast google-cast-sdk


    【解决方案1】:

    刚刚得知这是我的命名空间的问题。它现在连接。 问题是命名空间与我的接收器代码中的命名空间不匹配。

    fileprivate lazy var textChannel:TextChannel = {
    return TextChannel(namespace: NAMESPACE)
    }()
    

    【讨论】:

    • 您好,我也遇到了同样的问题,请问如何获取 currentCastSession 的命名空间以便匹配?
    • 在我的接收器应用程序的 index.html 中看起来像这样:window.messageBus = window.castReceiverManager.getCastMessageBus(NAMESPACE);
    • 另外,通用命名空间名称是 'urn:x-cast:com.google.cast.sample.helloworld'
    • 通用命名空间总是这样吗?
    • 不确定,但我猜是这样,并且默认接收者将其设置为他们的命名空间
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-24
    • 2012-03-30
    • 2017-06-04
    • 2015-01-30
    • 2014-09-18
    相关资源
    最近更新 更多