文档中可以看到Conversation实例中有lastMessage属性,其值可能会空。但为什么现在在已经聊过消息的对话里还是依然没有lastMessage? 这个是后台还没实现准备以后加入的么?
-
创建时间
16年7月19日
-
最后回复
16年7月28日
-
5
回复
-
1.4K
浏览
-
3
用户
-
1
链接
文档中可以看到Conversation实例中有lastMessage属性,其值可能会空。但为什么现在在已经聊过消息的对话里还是依然没有lastMessage? 这个是后台还没实现准备以后加入的么?
window.onload = function() {
//leanCloud
var APP_ID = '',
APP_KEY = '';
AV.init({
appId: APP_ID,
appKey: APP_KEY
});
var imUserObj;
var rt = new AV.Realtime({
appId: APP_ID,
region: 'cn'
});
rt.createIMClient('Tom2').then(function(tom) {
imUserObj = tom;
tom.createConversation({
members: ['Jerry'],
name: 'Tom3 & Jerry',
}).then(function(conversation) {
// 发送消息
return conversation.send(new AV.TextMessage('耗子,起床!'));
}).then(function(message) {
console.log('Tom3 & Jerry', '发送成功!');
imUserObj.getQuery().containsMembers(['Tom2']).find().then(function(conversations) {
console.log(conversations);
}).catch(console.error);
}).catch(console.error);
return tom.createConversation({
members: ['Jerry'],
name: 'Tom2 & Jerry',
});
}).then(function(conversation) {
// 发送消息
return conversation.send(new AV.TextMessage('耗子,起床!'));
}).then(function(message) {
console.log('Tom2 & Jerry', '发送成功!');
imUserObj.getQuery().containsMembers(['Tom2']).find().then(function(conversations) {
console.log(conversations);
}).catch(console.error);
}).catch(console.error);
};
抱歉文档没有更新
https://leancloud.github.io/js-realtime-sdk/docs/ConversationQuery.html#withLastMessagesRefreshed16
再查询会话时使用这个方法能再查询结果中得到 lastMessage,默认查询是不带 lastMessage 的。
主题 | 分类 | 回复 | 浏览 | 活动 |
---|---|---|---|---|
关于实时通信的云引擎hook | 实时通信 | 3 | 1.2K | 18-06-13 |
js浏览器刷新页面,再次进入创建对对话,该对话变成了已读对话 | 实时通信 | 0 | 973 | 19-04-12 |
应用部署失败,128 | 实时通信 | 1 | 999 | 19-09-2 |
用message 做客服,显示聊天室创建成功, 但是控制台没有看到 | 实时通信 | 1 | 878 | 16-03-15 |
chatkit 用户头像获取问题 | 实时通信 | 0 | 832 | 17-05-8 |