我将 LayerKit 0.17.3 与 Swift 一起使用,newConversationWithParticipants 总是在第一次抛出错误,域设置为 FMDatabase 并且出现“不是错误”错误。任何后续调用都会得到预期的结果。
初始错误:
Error with creating LYRConversation: Error Domain=FMDatabase Code=0 "not an error"
UserInfo={NSLocalizedDescription=not an error}
后续错误:(期望)
Error with creating LYRConversation: Error Domain=com.layer.LayerKit.Errors
Code=1013 "A conversation with a distinct participant list already exists
for participants [...]
这是查找/创建对话的功能:
@IBAction func didTapCompose(sender: AnyObject) {
var conversation : LYRConversation?
// create ATLConversationViewController
let controller = ConversationViewController(layerClient: self.layerClient)
controller.hidesBottomBarWhenPushed = true;
// get recipient (user objectID) from member object
let recipient = member.objectForKey(GlobalConstants.Parse.UserKey)?.objectId!
// create set for newConversationWithParticipants
let participants : Set = [recipient!]
do {
try conversation = layerClient.newConversationWithParticipants(participants, options: nil)
controller.conversation = conversation
} catch {
print("Error with creating LYRConversation: \(error)")
}
self.navigationController!.pushViewController(controller, animated: true)
}