[Top] iOS-OC-Custom Rongyun session list (custom cell)

I also introduced the session list of custom Rongyun in detail in one of my blog posts. Those who haven't seen it can click to see it;

[Top] iOS-OC-Custom Rongyun session list (custom cell) 


Here I mainly introduce how to set the avatar and nickname of the group cell in our custom conversation list, that is, the conversation of the ConversationType_GROUP type. Like other discussion groups or chat rooms, I will not explain it here. When many friends are watching the api documents or videos on the official website of Rongyun, there are detailed avatars and nicknames for setting personal information, but when there are groups in our conversation list, they find that the setting method is impossible. In fact, setting up groups is a separate method.

acting

First set the group's information proxy RCIMGroupInfoDataSource

[[RCIMsharedRCIM] setGroupInfoDataSource:self];

session type

Set the session type you want to display, which of course includes ConversationType_GROUP

//Set which types of sessions need to be displayed
    [self setDisplayConversationTypes:@[@(ConversationType_PRIVATE),@(ConversationType_DISCUSSION),@(ConversationType_CHATROOM),@(ConversationType_GROUP),@(ConversationType_APPSERVICE),@(ConversationType_SYSTEM)]];

proxy method

/*!
 group info provider
 
 The @discussion SDK needs to obtain group information and display it through the group information provider you implemented.
 */
@protocol RCIMGroupInfoDataSource <NSObject>

/*!
 Get group information
 
 @param groupId group ID
 @param completion Block that needs to be executed after the completion of obtaining group information [groupInfo: group information corresponding to the group ID]
 
 @discussion SDK obtains and displays user information through this method. Please return the user information corresponding to the user ID in the completion block.
 After you set the user information provider, when the SDK needs to display user information, it will call this method to request user information for display.
 */
- (void)getGroupInfoWithGroupId:(NSString *)groupId
                     completion:(void (^)(RCGroup *groupInfo))completion;

@end

The data type of the group is RCGroup, and here is an example:

- (void)getGroupInfoWithGroupId:(NSString *)groupId completion:(void (^)(RCGroup *))completion{
    if([groupId isEqualToString:@"123456"]){
        RCGroup *group = [[RCGroup alloc]init];
        group.groupId = groupId;
        group.groupName = @"Zhang Fujie's group";
        group.portraitUri = @"http://7xpx8n.com1.z0.glb.clouddn.com/logo256.png";
        return completion(group);
    }
}
I judge here that if the group ID (groupId) is 123456, set groupId, groupName and portraitUri for him.

Of course, when we actually do it, it is much more complicated. We must have a query interface. Through this interface, we pass the groupId of the group to get the groupName and portraitUri. We must also cache this data locally. The specific design Look at your needs.

Sample effect




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325570455&siteId=291194637