我知道我会在房间历史记录中收到最后50条消息。但是,如果聊天室历史记录的消息少于50条,我将如何知道会收到多少条消息?
答案 0 :(得分:1)
加入房间后
[[QBChat instance] joinRoom:testRoom];
您将收到委托中的所有邮件,并以此方式计算
static int count = 0;
- (void)chatRoomDidReceiveMessage:(QBChatMessage *)message fromRoom:(NSString *)roomName{
NSLog(@"Did receive message: %@, from room %@", message, roomName);
++count;
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(receivedAllMessages) object:nil];
[self performSelector:@selector(receivedAllMessages) withObject:nil afterDelay:1.0];
}
- (void)receivedAllMessages{
NSLog(@"%d", count);
}
答案 1 :(得分:0)
Quickblox提供单独的请求以获取特定对话框的大量聊天消息:
类似于javascript:
var params = {chat_dialog_id: dialogId, count: 1};
QB.chat.message.list(params, function(err, messagesCount) {
if (messagesCount) {
}else{
console.log(err);
}
});