Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在消息聊天页退出将应用挂在后台,返回应用重连IM,会监听到添加新消息,第一条消息被重复添加 #33

Open
ASongTong opened this issue Nov 5, 2024 · 1 comment
Assignees

Comments

@ASongTong
Copy link

void addOnNewMsgListener() {
CustomLogger.instance.d(["添加新消息监听"]);
WKIM.shared.messageManager.addOnNewMsgListener('chatNewMsg', (msgs) {
CustomLogger.instance.d(["收到信息消息"]);
for (var msg in msgs) {
if (msg.isDeleted == 0 && msg.channelID == channelID && msg.channelType == channelType) {
addMessage(msg);
}
if (msg.setting.receipt == 1) {
// 消息需要回执
messageReceipt(msg);
}
}
});
}
在消息列表中msgs为三条,返回应用重连IM发现addOnNewMSgListener触发,同时msgs变为四条,第一条重复出现一次,然后触发addMessage将重复出现的第一条消息添加进列表中
flutter sdk版本:1.5.6
android

@tangtaoit tangtaoit transferred this issue from WuKongIM/WuKongIM Nov 16, 2024
@No8blackball
Copy link
Collaborator

应该是应用回到前台,调用了同步最近会话把历史消息同步下来导致的。UI上需要判断收到的新消息是否属于当前聊天,和判断新消息是否已经显示在UI了(可通过clientMsgNo判断)。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants