I'm using Quick blox and I downloaded Sample app (https://github.com/QuickBlox/quickblox-ios-sdk/tree/master/sample-chat) which uses QMChatViewController
, QMServices
.
I am using MessageStatusStringBuilder
class methods in ChatViewController
to get the status (read/delivered/sent) of message (here this message is not a string it is an instance of QBChatMessage
) in ChatViewController
so that I'm showing the message status when ever QMChatServiceDelegate
calls backs were called.
I have a requirement to show the status(read/delivered/sent) of last message in DialogsViewController
under each dialog also.
But in DialogsViewController lastTextMessage
is a string but not a QBChatMessage
instance.
How to update this message status?
One plus point is I will get callbacks from this QMChatServiceDelegate
in DialogsViewController
also, even I can't find the status of message from that.
So how to handle this?
First you should get the message with the extended request using date_send
as key and dialog's lastMessageDate
as value. Then using the instance of the MessageStatusStringBuilder
class you can get the status of the last message.
QBChatDialog *dialog = ... // your dialog
QBResponsePage *resPage = [QBResponsePage responsePageWithLimit:1 skip:0];
NSMutableDictionary *extendedRequest = @{@"date_sent" : [NSString stringWithFormat:@"%tu", (NSUInteger)[dialog.lastMessageDate timeIntervalSince1970]]}.mutableCopy;
[QBRequest messagesWithDialogID:dialog.ID extendedRequest:extendedRequest forPage:resPage successBlock:^(QBResponse *response, NSArray *messages, QBResponsePage *responcePage) {
NSLog(@"status = %@",[self.stringBuilder statusFromMessage:[messages firstObject]]);
} errorBlock:^(QBResponse *response) {
NSLog(@"error: %@", response.error);
}];