无法使用新的 Conversations API 获取带有频道 ID 的频道

问题描述

迁移到新的 Conversations API 后,

尝试获取带有频道 ID 的频道时,出现以下错误

<TCHResult: 0x6000039e60e0> - code: 102; text: Conversation with given sid not found.

以下是我遵循的步骤:

首先,使用适当的 jwt 令牌初始化聊天客户端:

TwilioConversationsClient.conversationsClient(withToken: token,properties: nil,delegate: self) { (result,chatClient) in
 self.client = chatClient
 self.client?.delegate = self
}

第二,从后端获取频道ID,并尝试获取带有ID的频道。我确保频道 ID 有效,并且在迁移之前存在聊天的预对话。

self.client?.conversation(withSidOrUniqueName: channelId,completion: { (result,conversation) in
   // Error here,conversation is nil
})

当我在获取频道之前打印客户端详细信息时,我得到了这个:

client Optional(<<TCHUser: 0x6000038fe700>: identity: '100360',friendlyName: 'xxxxx',attributes: '<TCHJsonAttributes: 0x600003bcbe50>'>) Optional(2) Optional(2)

用户详细信息及其同步状态和连接状态均有效。

但是我还是没有得到频道。不确定我错过了什么。

解决方法

在调用客户端之前,您应该等待同步事件。

在您收到来自 – conversationsClient:synchronizationStatusUpdated:.completed 同步状态后,客户端将完全正常运行