Mario Frade
Mario Frade

Reputation: 273

How many messages in Quickblox chat rooms?

I know that I'll receive the last 50 messages in the room history. But how to know how many messages I will receive if the chat room history has less than 50 messages?

Upvotes: 1

Views: 276

Answers (2)

Mayur Shah
Mayur Shah

Reputation: 3449

Quickblox provide a separate request to get a number of chat messages for particular dialog:
Like in javascript :

var params = {chat_dialog_id: dialogId, count: 1};
QB.chat.message.list(params, function(err, messagesCount) {
  if (messagesCount) {

  }else{
    console.log(err);
  }
});

Upvotes: 0

Rubycon
Rubycon

Reputation: 18346

After join room

[[QBChat instance] joinRoom:testRoom];

you will receive all messages in delegate and count this way

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);
}

Upvotes: 1

Related Questions