Skip to main content

Multi-Device Synchronization for Do Not Disturb/Pinned Conversations

The IMLib SDK provides a conversation status (pinned or Do Not Disturb) synchronization mechanism. By setting a conversation status synchronization listener, your app can monitor real-time changes to conversation status when modified on other devices.
To implement this feature, you need to comply with the RCConversationStatusChangeDelegate protocol.

Setting the Delegate

[[RCCoreClient sharedCoreClient] setRCConversationStatusChangeDelegate:self];

Conversation Status Update Delegate Methods

@protocol RCConversationStatusChangeDelegate <NSObject>

/**
Callback for IMLib conversation status synchronization

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

@end

RCConversationStatusInfo Description

ParameterTypeDescription
conversationTypeRCConversationTypeConversation type
targetIdNSStringConversation ID
channelIdNSStringBusiness identifier of the conversation
conversationStatusTypeRCConversationStatusTypeType of conversation status change: RCConversationStatusType_Mute = 1 (Do Not Disturb); RCConversationStatusType_Top = 2 (Pinned)
conversationStatusvalueintValue of conversation status change (see conversationStatusvalue description)
notificationLevelRCPushNotificationLevelConversation Do Not Disturb type (see RCPushNotificationLevel description)
  • conversationStatusvalue Description:

    • When conversationStatusType == RCConversationStatusType_Mute:
      conversationStatusvalue = 1 (Notifications enabled)
      conversationStatusvalue = 0 (Do Not Disturb)
    • When conversationStatusType == RCConversationStatusType_Top:
      conversationStatusvalue = 0 (Not pinned)
      conversationStatusvalue = 1 (Pinned)
  • RCPushNotificationLevel Description:
    notificationLevel is valid only when conversationStatusType = RCConversationStatusType_Mute.

    typedef NS_ENUM(NSInteger, RCPushNotificationLevel) {
    /*!
    All message notifications (receives all message notifications - explicitly disables Do Not Disturb)
    @discussion For ultra groups with all message notifications enabled:
    @ mentions will always trigger push notifications
    Regular message notifications are subject to the ultra group server's default push frequency settings
    */
    RCPushNotificationLevelAllMessage = -1,
    /*!
    Not set (inherits group or app-level settings). Value 0 indicates unset in legacy data
    */
    RCPushNotificationLevelDefault = 0,
    /*!
    For group chats/ultra groups: notifies on @all or @mentions containing self; for 1:1 chats: no notifications
    */
    RCPushNotificationLevelMention = 1,
    /*!
    For group chats/ultra groups: notifies only on @mentions containing self (excludes @all); for 1:1 chats: no notifications
    */
    RCPushNotificationLevelMentionUsers = 2,
    /*!
    For group chats/ultra groups: notifies only on @all; for 1:1 chats: no notifications
    */
    RCPushNotificationLevelMentionAll = 4,
    /*!
    Message notifications blocked (no notifications received)
    */
    RCPushNotificationLevelBlocked = 5,
    };

Sample Code

- (void)conversationStatusDidChange:(NSArray<RCConversationStatusInfo  *> *)conversationStatusInfos {
for (RCConversationStatusInfo *statusInfo in conversationStatusInfos) {
/*!
When conversationStatusType = RCConversationStatusType_Mute:
conversationStatusvalue = 1 (Notifications enabled), 0 (Do Not Disturb)
*/
if (RCConversationStatusType_Mute == statusInfo.conversationStatusType) {
int blockStatus = statusInfo.conversationStatusvalue; //1 = enabled, 0 = Do Not Disturb
}
/*!
When conversationStatusType = RCConversationStatusType_Top:
conversationStatusvalue = 0 (Not pinned), 1 (Pinned)
*/
else if (RCConversationStatusType_Top == statusInfo.conversationStatusType) {
BOOL isTop = (statusInfo.conversationStatusvalue == 1); //0 = not pinned, 1 = pinned
}
}
}

Multi-Device Conversation Status Synchronization Completion Delegate Method

After successful connection, the IMLib SDK synchronizes all conversation statuses for the current user. Upon completion, it notifies the app via the conversationStatusDidSync: method of the RCConversationStatusChangeDelegate protocol.

Sample Code

- (void)conversationStatusDidSync:(RCErrorCode)code {
// TODO Business logic
}