I have been using Quickblox for iOS for a while now. So far everything seems to be working fine. There is just one problem that i am facing i.e. While sending fast/quick messages like 4,5 messages in a second, then the sorting becomes a problem as the date_sent/dateSent becomes same for all messages. Even in the custom attributes of QBChatMessages, date_sent that is in integer shows the same number for all 4,5 messages when sent with in same second.
Can anyone please guide me how to sort the messages ? Even though while chatdidReceivemessage does receive the message in sorted order, i can save the messages in NSArray, as it is to preserve the order. But once i try to save in Coredata and fetch back based on date_sent/dateSent, the order is not preserved.
Yes, Quickblox store date sent of messages as an integer value indeed. But there is a solution for you. You should sort messages not only by date sent, but also ID field. ID string contains of such things as date sent, an unique machine identifier, etc. You can see more detailed information on how mongoDBID works here.
Here is an example code snippet for you (from QMServices project):
NSMutableOrderedSet *datasource = [self dataSourceWithDialogID:dialogID];
NSSortDescriptor *dateSentDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"dateSent" ascending:YES];
NSSortDescriptor *idDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"ID" ascending:YES];
[datasource sortUsingDescriptors:@[dateSentDescriptor, idDescriptor]];
Long story short, in order to sort messages with same dateSent value, compare them by its ID string.