自定义消息无法成功发送到服务器
Guoxweii opened this issue · comments
Base Info for this issue
我自定义了一个聊天cell, 点击发送后成功发送, 聊天页面显示成功. 但是再次打开该对话,自定义消息已经消失了,所以我怀疑是没有保存到服务器上。
- ChatKit Version:0.10.1
- App-ID: #
- Language:Swift
- iOS System Version:iOS10.3.3
- Prototype(是否是真机):YES
- Issue Type:Bug
1. How to repeat the problem.
- 自定义了一个输入框插件 LCCKInputPluginRefuse.swift
import ChatKit
import RxSwift
import Dollar
let LCCKInputViewPluginTypeRefuse: LCCKInputViewPluginType = LCCKInputViewPluginType(rawValue: 4)!
class LCCKInputPluginRefuse: LCCKInputViewPlugin, LCCKInputViewPluginSubclassing, StoryboardHelper {
var disposeBag = DisposeBag()
class func classPluginType() -> LCCKInputViewPluginType {
return LCCKInputViewPluginTypeRefuse
}
override func pluginDidClicked() {
sendCustomMessage(object: "any", error: nil)
}
override var pluginTitle: String! {
return "不合适"
}
override var pluginIconImage: UIImage! {
return UIImage(named: "Logo")
}
override var pluginContentView: UIView! {
return nil
}
func sendCustomMessage(object: Any?, error: Error?) {
if !conversationViewController.isAvailable {
conversationViewController.sendLocalFeedbackTextMessge("简历发送失败")
return
}
let conversation = conversationViewController.getConversationIfExists()!
let userId = conversation.members!.first { String(describing: $0) == String(UserSession.instance.user.value!.id) }!
let message = LCCKResumeMessage(userId: String(describing: userId), conversation: conversation)
conversationViewController.sendCustomMessage(message, progressBlock: { percentage in
print(percentage)
}, success: { (_, _) in
self.conversationViewController.sendLocalFeedbackTextMessge("简历发送成功")
}) { (successed, error) in
print(error!)
}
}
}
- 自定义了聊天消息
文件 LCCKResumeMessage.swift
import ChatKit
let AVIMMessageMediaTypeResume: AVIMMessageMediaType = AVIMMessageMediaType(rawValue: 1)!
class LCCKResumeMessage: AVIMTypedMessage, AVIMTypedMessageSubclassing {
class func classMediaType() -> AVIMMessageMediaType {
return AVIMMessageMediaTypeResume
}
convenience init(userId: String, conversation: AVIMConversation) {
self.init()
self.lcck_setObject("简历", forKey: LCCKCustomMessageTypeTitleKey)
self.lcck_setObject("这是一条简历消息,当前版本过低无法显示,请尝试升级APP查看", forKey: LCCKCustomMessageDegradeKey)
self.lcck_setObject("有人向您发送了一条简历消息,请打开APP查看", forKey: LCCKCustomMessageSummaryKey)
self.lcck_setObject(conversation.lcck_type(), forKey: LCCKCustomMessageConversationTypeKey)
self.lcck_setObject(userId, forKey: "userId")
}
override init() {
super.init()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
文件LCCKResumeMessageCell.swift
import ChatKit
class LCCKResumeMessageCell: LCCKChatMessageCell, LCCKChatMessageCellSubclassing {
class func classMediaType() -> AVIMMessageMediaType {
return AVIMMessageMediaTypeResume
}
override func setup() {
let view = UIView()
view.backgroundColor = .red
contentView.addSubview(view)
view.snp.makeConstraints { make in
make.height.equalTo(120)
make.edges.equalTo(contentView).inset(UIEdgeInsets(top: 15, left: 15, bottom: 15, right: 15))
}
self.updateConstraintsIfNeeded()
super.setup()
}
override func configureCell(withData message: Any!) {
super.configureCell(withData: message)
}
}
点击后聊天列表中显示了自定义的消息(图中最后一个红色cell)
点击发送后的日志:
2017-08-09 12:17:31.643944+0800 yunji[7440:1395350] [INFO] -[AVIMWebSocketWrapper sendCommand:] [Line 625]
------ BEGIN LeanCloud IM Out Command ------
content: <AVIMGenericCommand 0x1703c4830>: {
cmd: direct
peerId: "11"
i: 20
directMessage {
r: true
cid: "59835509f9d06fd6c92a0ea7"
transient: false
}
}
------ END ---------------------------------
2017-08-09 12:17:31.767280+0800 yunji[7440:1388084] [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<SnapKit.LayoutConstraint:0x1746ac900@LCCKResumeMessageCell.swift#14 UIView:0x155a66880.height == 120.0>",
"<SnapKit.LayoutConstraint:0x1746ac540@LCCKResumeMessageCell.swift#15 UIView:0x155a66880.top == UITableViewCellContentView:0x153ddcd60.top + 15.0>",
"<SnapKit.LayoutConstraint:0x1744becc0@LCCKResumeMessageCell.swift#15 UIView:0x155a66880.bottom == UITableViewCellContentView:0x153ddcd60.bottom - 15.0>",
"<NSLayoutConstraint:0x17448efb0 UITableViewCellContentView:0x153ddcd60.height == 44>"
)
Will attempt to recover by breaking constraint
<SnapKit.LayoutConstraint:0x1746ac900@LCCKResumeMessageCell.swift#14 UIView:0x155a66880.height == 120.0>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
在上面的日志我没有看到相关的错误信息,并且我使用的是函数
sendCustomMessage(_ customMessage: AVIMTypedMessage!, progressBlock: AVOSCloud.AVProgressBlock!, success: ChatKit.LCCKBooleanResultBlock!, failed: ChatKit.LCCKBooleanResultBlock!)
在发送消息,但是三个block我都打了断点,一个都没有触发,所以我现在有点不知道怎么调试了
我改用 objecct-c 发出去了