Multi-End Synchronization for Do Not Disturb and Pinning
The SDK provides a synchronization mechanism for conversation status (pinned or do not disturb). By setting a conversation status synchronization listener, you can monitor changes in conversation status in real-time on this end when modifications are made on other ends.
Before version 5.10.0
, there might be inaccuracies in the unread message count. It is recommended to use version 5.10.0
or higher.
Listener Description
The RongIMClient
provides a ConversationStatusListener
listener. After setting the listener, the following method will be triggered when the conversation status (pinned or do not disturb) changes:
public interface ConversationStatusListener {
void onStatusChanged(ConversationStatus[] conversationStatus);
}
The onStatusChanged
method returns a list of conversationStatus
with the following parameters:
Parameter | Type | Description |
---|---|---|
conversationType | ConversationType | The type of conversation. |
targetId | String | The conversation ID. |
isTop | boolean | Whether the conversation is set as pinned. |
level | PushNotificationLevel | The do not disturb level of the conversation. The SDK supports multi-end synchronization of do not disturb levels starting from version 5.2.5. For specific level descriptions, refer to the Do Not Disturb Function Overview. |
notificationStatus | ConversationNotificationStatus | The conversation notification status. Only supports two states: notify (1 ) or do not disturb (0 ). |
Setting the Listener
Set the multi-end synchronization listener for conversation status (pinned and do not disturb).
// Synchronization listener
RongIMClient.ConversationStatusListener listener = new RongIMClient.ConversationStatusListener() {
@Override
public void onStatusChanged(ConversationStatus[] conversationStatus) {
if (conversationStatus == null) {
return;
}
for (ConversationStatus status : conversationStatus) {
Conversation.ConversationType conversationType = status.getConversationType(); // Get the conversation type
String targetId = status.getTargetId(); // Get the conversation ID
boolean isTop = status.isTop(); // Get whether the conversation is currently pinned
IRongCoreEnum.PushNotificationLevel level = status.getNotificationLevel(); // Get PushNotificationLevel (added in 5.2.5)
Conversation.ConversationNotificationStatus notificationStatus = status.getNotifyStatus(); // Get the current do not disturb status of the conversation.
}
}
};
RongIMClient.getInstance().setConversationStatusListener(listener); // Set the listener