Multi-Device Read Status Synchronization
In instant messaging services, a single user account may be logged in on multiple devices. Only after enabling the Multi-Device Message Synchronization service will RC synchronize message data across multiple devices. However, the read/unread status of messages in conversations on each device is stored locally. Therefore, applications may want to synchronize the read/unread status of specified conversations on the user's currently logged-in device to other endpoints.
If the SDK version ≦ 5.6.2, multi-device synchronization of read status for system conversations is not supported.
Initiating Conversation Read Status Synchronization
[[RCIMClient sharedRCIMClient] syncConversationReadStatus:ConversationType_PRIVATE targetId:@"targetId" time:1626422416809 success:^{
} error:^(RCErrorCode nErrorCode) {
}];
Parameter | Type | Description |
---|---|---|
conversationType | RCConversationType | Conversation type |
targetId | NSString | Conversation ID |
timestamp | long long | Message timestamp, indicating that messages with a timestamp less than or equal to this value are marked as read |
Receiving Multi-Device Synchronization Read Status Notifications
IMLib will dispatch a RCLibDispatchReadReceiptNotification
notification when it receives a read status synchronization notification. At this point, the message status in the message database has already been updated to read. The application can update the conversation UI based on the notification, marking messages before messageTime
as read in the UI.
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(didReceiveReadReceiptNotification:)
name:RCLibDispatchReadReceiptNotification
object:nil];
The object
of the Notification is nil
, and the userInfo
is an NSDictionary
object.
- (void)didReceiveReadReceiptNotification:(NSNotification *)notification {
RCConversationType conversationType = (RCConversationType)[notification.userInfo[@"cType"] integerValue];
long long readTime = [notification.userInfo[@"messageTime"] longLongValue];
NSString *targetId = notification.userInfo[@"tId"];
NSString *senderUserId = notification.userInfo[@"fId"];
}
NSDictionary
object key
value descriptions:
Key | Type | Description |
---|---|---|
cType | NSNumber | Conversation type |
messageTime | NSNumber | Message timestamp, indicating that messages with a timestamp less than or equal to this value are marked as read |
tId | NSString | Target ID of A |
fId | NSString | Target ID of B |