Multi-Device Sync for Do Not Disturb/Top
IMLib SDK provides a conversation status (top or Do Not Disturb) synchronization mechanism. By setting up a conversation status synchronization listener, when the conversation status is modified on other devices, you can listen to the conversation status changes in real-time on this device.
To implement this feature, you need to conform to the RCConversationStatusChangeDelegate protocol.
Set the Delegate
[[RCCoreClient sharedCoreClient] setRCConversationStatusChangeDelegate:self];
Conversation Status Update Delegate Method
@protocol RCConversationStatusChangeDelegate <NSObject>
/**
Callback for IMLib conversation status synchronization
@param conversationStatusInfos Array of changed conversation status information
*/
- (void)conversationStatusDidChange:(NSArray<RCConversationStatusInfo *> *)conversationStatusInfos;
@end
RCConversationStatusInfo Description
| Parameter | Type | Description |
|---|---|---|
| conversationType | RCConversationType | Conversation type |
| targetId | NSString | Conversation ID |
| channelId | NSString | Business identifier of the conversation |
| conversationStatusType | RCConversationStatusType | Type of conversation status change. RCConversationStatusType_Mute = 1 (Do Not Disturb); RCConversationStatusType_Top = 2 (Top). |
| conversationStatusvalue | int | Value of the conversation status change. See conversationStatusvalue description for details |
| notificationLevel | RCPushNotificationLevel | Conversation Do Not Disturb type. See RCPushNotificationLevel description for details |
-
conversationStatusvalueDescription-
If conversationStatusType == RCConversationStatusType_Mute, conversationStatusvalue = 1 means notification enabled, conversationStatusvalue = 0 means Do Not Disturb.
-
If conversationStatusType == RCConversationStatusType_Top, conversationStatusvalue = 0 means not pinned to top, conversationStatusvalue = 1 means pinned to top.
-
-
RCPushNotificationLevelDescriptionWhen conversationStatusType = RCConversationStatusType_Mute, the notificationLevel value is valid.
typedef NS_ENUM(NSInteger, RCPushNotificationLevel) {
/*!
All message notifications (receive all message notifications -- explicitly disable Do Not Disturb)
@discussion When ultra group is set to all message notifications:
Mention messages will always receive push notifications
Regular message push frequency is affected by the ultra group server's default push frequency setting, so not all regular messages can be notified
*/
RCPushNotificationLevelAllMessage = -1,
/*!
Not set (query group or app level settings), 0 in existing data means not set
*/
RCPushNotificationLevelDefault = 0,
/*!
For group chat and ultra group: notify when @all or @member list includes yourself; for one-to-one chat: no message notification
*/
RCPushNotificationLevelMention = 1,
/*!
For group chat and ultra group: notify when @member list includes yourself, no notification for @all; for one-to-one chat: no message notification
*/
RCPushNotificationLevelMentionUsers = 2,
/*!
For group chat and ultra group: notify for @all, no notification in other cases; for one-to-one chat: no message notification
*/
RCPushNotificationLevelMentionAll = 4,
/*!
Message notifications are blocked, i.e., no message notifications are received
*/
RCPushNotificationLevelBlocked = 5,
};
Code Example
- (void)conversationStatusDidChange:(NSArray<RCConversationStatusInfo *> *)conversationStatusInfos {
for (RCConversationStatusInfo *statusInfo in conversationStatusInfos) {
/*!
If conversationStatusType = RCConversationStatusType_Mute, conversationStatusvalue = 1 means notification enabled, conversationStatusvalue = 0 means Do Not Disturb.
*/
if (RCConversationStatusType_Mute == statusInfo.conversationStatusType) {
int blockStatus = statusInfo.conversationStatusvalue;// 1 means notification enabled, 0 means Do Not Disturb
}
/*!
If conversationStatusType = RCConversationStatusType_Top, conversationStatusvalue = 0 means not pinned to top, conversationStatusvalue = 1 means pinned to top.
*/
else if (RCConversationStatusType_Top == statusInfo.conversationStatusType) {
BOOL isTop = (statusInfo.conversationStatusvalue == 1);// 0 means not pinned to top, 1 means pinned to top
}
}
}
Multi-Device Conversation Status Sync Completion Delegate Method
After a successful connection, IMLib SDK will synchronize all conversation statuses of the current user. Once synchronization is complete, it will notify the app through the conversationStatusDidSync: method of the RCConversationStatusChangeDelegate delegate that conversation status synchronization is complete.
Code Example
- (void)conversationStatusDidSync:(RCErrorCode)code {
// TODO Business logic
}