Conversation Pinning
Global IM UIKit supports displaying pinned conversations, which are sorted in reverse chronological order based on the latest message.
Usage
In the conversation list, swipe right on a conversation to reveal the Pin/Unpin button. Clicking it will update the pinned status of the conversation. Once a conversation is pinned, this status will be synchronized with the server. RC automatically synchronizes the pinned conversation status data across devices. Clients can receive synchronization notifications via listeners.
Setting Pinned Status
The event for setting the conversation pin button calls the toggleTop:
method in RCChatListViewModel
:
/// Pin/Unpin
- (void)toggleTop:(RCChatModel *)model;
Listening for Pinned Status Synchronization
The IM service supports a conversation status (pinned status and Do Not Disturb status) synchronization mechanism. RCChatListViewModel
internally listens for conversation status synchronization. If the conversation status changes, the conversation list will be refreshed immediately.
Customization
The buttons that appear when swiping left or right in the conversation list can be customized, including the pin button. If you need to control the display order of the pin button in the conversation list, you can also achieve this by modifying the data source. In a custom conversation list page, override the listView:cellSwipeItemsAtIndexPath:forDirection:
method:
- (NSArray<RCSwipeItem *> *)listView:(RCChatListView *)listView
cellSwipeItemsAtIndexPath:(NSIndexPath *)indexPath
forDirection:(RCSwipeDirection)direction {
NSArray *items = [super listView:listView cellSwipeItemsAtIndexPath:indexPath forDirection:direction];
NSMutableArray *mutableItems = [NSMutableArray array];
if (items.count) {
[mutableItems addObjectsFromArray:items];
}
for (RCSwipeItem *item in mutableItems) {
if (item.tag == RCSwipeItemTagTop) {
RCSwipeItem *customItem = [RCSwipeItem itemWithImage:CustomImage
title:CustomTitle
backgroundColor:CustomColor
action:item.action];
[mutableItems replaceObjectAtIndex:[mutableItems indexOfObject:item]
withObject:customItem];
break;
}
}
return [mutableItems copy];
}
For more information on pinning features, refer to the IMLib documentation Conversation Pinning under Get Conversation Pinned Status and Get Pinned Conversation List.