Skip to main content

Multi-Device Synchronization for Do Not Disturb/Pin to Top

The SDK provides a synchronization mechanism for conversation status (pin to top or do not disturb). By setting up a conversation status synchronization listener, you can monitor real-time changes in conversation status on your device when modifications are made on other devices.

To implement this feature, you need to adhere to the RCConversationStatusChangeDelegate protocol.

Setting the Delegate

[[RCIMClient sharedRCIMClient] setRCConversationStatusChangeDelegate:self];

Delegate Method

@protocol RCConversationStatusChangeDelegate <NSObject>

/**
Callback for IMLib conversation status synchronization

@param conversationStatusInfos Array of changed conversation statuses
*/
- (void)conversationStatusDidChange:(NSArray<RCConversationStatusInfo *> *)conversationStatusInfos;

@end

RCConversationStatusInfo Explanation

ParameterTypeDescription
conversationTypeRCConversationTypeConversation type
targetIdNSStringConversation ID
channelIdNSStringBusiness identifier of the conversation
conversationStatusTypeRCConversationStatusTypeType of conversation status change (RCConversationStatusType_Mute = 1 // Do Not Disturb; RCConversationStatusType_Top = 2 // Pin to Top)
conversationStatusvalueintValue of the conversation status change, see explanation for conversationStatusvalue
notificationLevelRCPushNotificationLevelType of conversation do not disturb, see explanation for RCPushNotificationLevel
  • conversationStatusvalue Explanation

    • If conversationStatusType == RCConversationStatusType_Mute, conversationStatusvalue = 1 means notify, conversationStatusvalue = 0 means do not disturb.

    • If conversationStatusType == RCConversationStatusType_Top, conversationStatusvalue = 0 means not pinned, conversationStatusvalue = 1 means pinned.

  • RCPushNotificationLevel Explanation

    When conversationStatusType = RCConversationStatusType_Mute, notificationLevel is a valid value.

    typedef NS_ENUM(NSInteger, RCPushNotificationLevel) {
    /*!
    Notify for all messages (receive notifications for all messages -- explicitly turn off do not disturb)
    @discussion When a ultra group is set to notify for all messages
    @ messages will always receive push notifications
    The frequency of push notifications for regular messages is affected by the default push frequency settings of the ultra group server, and it is not possible to notify all regular messages
    */
    RCPushNotificationLevelAllMessage = -1,
    /*!
    Not set (query group or APP level settings), 0 in existing data means not set
    */
    RCPushNotificationLevelDefault = 0,
    /*!
    Notify for group chat, ultra group @all or @member list includes self; for one-to-one chat, it means no notification
    */
    RCPushNotificationLevelMention = 1,
    /*!
    Notify for group chat, ultra group @member list includes self, @all does not notify; for one-to-one chat, it means no notification
    */
    RCPushNotificationLevelMentionUsers = 2,
    /*!
    Notify for group chat, ultra group @all, other cases do not notify; for one-to-one chat, it means no notification
    */
    RCPushNotificationLevelMentionAll = 4,
    /*!
    Message notifications are blocked, i.e., no message notifications are received
    */
    RCPushNotificationLevelBlocked = 5,
    };

Example Code

- (void)conversationStatusDidChange:(NSArray<RCConversationStatusInfo  *> *)conversationStatusInfos {

for (RCConversationStatusInfo *statusInfo in conversationStatusInfos) {
/*!
If conversationStatusType = RCConversationStatusType_Mute, conversationStatusvalue = 1 means notify, conversationStatusvalue = 0 means do not disturb.
*/
if (RCConversationStatusType_Mute == statusInfo.conversationStatusType) {
int blockStatus = statusInfo.conversationStatusvalue;//1 means notify, 0 means do not disturb
}
/*!
If conversationStatusType = RCConversationStatusType_Top, conversationStatusvalue = 0 means not pinned, conversationStatusvalue = 1 means pinned.
*/
else if (RCConversationStatusType_Top == statusInfo.conversationStatusType) {
BOOL isTop = (statusInfo.conversationStatusvalue == 1);//0 means not pinned, 1 means pinned
}
}
}