我在 5 分钟后收到错误描述。这是因为 sendbird sdk 的自动重新连接。那么,是否有任何方法可以停止自动连接或减少错误消息的到达时间。
这是我尝试过的,
let preSendMessage = channel.sendFileMessage(withBinaryData: data!, filename: "demo", type: mimeType! as String, size: UInt((data?.count)!), thumbnailSizes: [thumbnailSize!], data: "", customType: "", progressHandler: nil, completionHandler: { (fileMessage, error) in
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .milliseconds(150), execute: {
let preSendMessage = self.preSendMessages[(fileMessage?.requestId)!]
self.preSendMessages.removeValue(forKey: (fileMessage?.requestId)!)
if error != nil {
self.resendableMessages[(fileMessage?.requestId)!] = preSendMessage
self.resendableFileData[(preSendMessage as! SBDFileMessage).requestId!] = [
"data": data as AnyObject,
"type": mimeType as AnyObject,
]
self.chatTableView.reloadData()
DispatchQueue.main.async {
self.chatTableView.scrollToLastRow(animated: true)
}
return
}
if fileMessage != nil {
self.resendableMessages.removeValue(forKey: (fileMessage?.requestId)!)
self.resendableFileData.removeValue(forKey: (fileMessage?.requestId)!)
self.messages[self.messages.index(of: preSendMessage as! SBDFileMessage)!] = fileMessage!
DispatchQueue.main.async {
self.chatTableView.reloadData()
DispatchQueue.main.async {
self.chatTableView.scrollToLastRow(animated: true)
}
}
}
})
})