Query a conversation
Introduction
ZIM supports querying detailed information of a single conversation by specifying the conversation ID, and also supports querying detailed information of multiple specified conversations in batches.
Query a single conversation
After the login, a user can use the queryConversation interface to specify the conversation ID and conversation type to get detailed information about the corresponding conversation, including the conversation name, unread count, and notification status.
// Query conversation information
ZIM.getInstance().queryConversation("conversationID", ZIMConversationType.peer).then((value){
// Query succeeded
}).catchError((onError){
// Query failed, you can print the error code and error message to troubleshoot the error cause, refer to the ZIM official website error code documentation
});Batch query conversations
Starting from version 3.3.0, ZIM supports querying conversations in batches.
After the login, a user can call the queryConversations interface and pass in the list of conversation base information to be queried (ZIMConversationBaseInfo), to get detailed information of multiple specified conversations at once (including the conversation name, unread count, and notification status), without calling the queryConversation interface multiple times.
- Up to 100 conversations can be queried at a time. This feature is available after login and unavailable after logout.
- Successfully queried conversations are returned through
conversationsin the callback, and the conversation base information that failed to be queried is returned througherrorConversationInfos, based on which you can retry or degrade the process.
// Build the list of conversation base information to be queried
ZIMConversationBaseInfo info = ZIMConversationBaseInfo();
info.conversationID = "conversationID";
info.conversationType = ZIMConversationType.peer;
// Batch query conversation information
ZIM.getInstance().queryConversations([info]).then((value){
// Callback for the result of the batch query conversation operation
// value.conversations is the list of successfully queried conversations
// value.errorConversationInfos is the list of conversation base information that failed to be queried, based on which you can retry or degrade the process
}).catchError((onError){
// You can print the error code and error message to troubleshoot the error cause, referring to the ZIM official website error code documentation
});