User Profile Hosting Overview
This feature is supported starting from version 5.12.0.
Introduction to User Profile Hosting
Before version 5.12.0, IMKit's chat UI and conversation list only supported displaying user and group information via the User Info Provider Delegate Pattern.
Starting from version 5.12.0, IMKit allows switching to User Profile Hosting for displaying user/group information in the chat UI and conversation list. It also introduces new hosted pages like user profiles, friend lists, and group profiles.
After switching to User Profile Hosting, user information will no longer be fetched through the provider pattern. In the chat UI and conversation list, user information from message bodies takes precedence over hosted profiles.
Note: IMKit does not update conversation list information in real-time. The latest data is fetched when entering the interface.
Enabling User Profile Hosting
Before using this feature, you must activate User Profile Hosting in the Console.
By default, IMKit SDK uses the User Info Provider Delegate Pattern to display user/group information. To switch to User Profile Hosting, manually configure:
[RCIM sharedRCIM].currentDataSourceType = RCDataSourceTypeInfoManagement;
- Switch the user info source after initializing the IMKit SDK but before connecting to RC Chat.
- After switching, user/group information in conversation lists and chat UIs will be retrieved from IMLib's hosting APIs and cached in memory (valid for the app's lifecycle).
- To update user/group information, only use the RCIM interfaces listed below.
- Cached user profiles are primarily used for displaying names, aliases, and avatars in IMKit. For other data, directly use IMLib-level hosting APIs.
Updating Information
After switching to User Profile Hosting, use the following RCIM interfaces for updates:
Update Current User Profile
Interface Prototype
/// Update current user's profile
///
/// - Parameter profile: User profile
/// - Parameter successBlock: Success callback
/// - Parameter errorBlock: Failure callback
///
/// - Since: 5.16.0
- (void)updateMyUserProfile:(RCUserProfile *)profile
successBlock:(void (^)(void))successBlock
errorBlock:(nullable void (^)(RCErrorCode errorCode, NSArray<NSString *> * _Nullable errorKeys))errorBlock;
Parameters
RCUserProfile attributes:
Attribute | Type | Description |
---|---|---|
name | NSString | Nickname (max 32 chars) |
portraitUri | NSString | Avatar URL (max 128 chars) |
uniqueId | NSString | User app ID (letters/numbers, max 32 chars). Note: Client SDK cannot set this field. |
NSString | Email (max 128 chars) | |
birthday | NSString | Birthday (max 32 chars) |
gender | RCUserGender | Gender |
location | NSString | Location (max 32 chars) |
role | NSUInteger | Role (0-100) |
level | NSUInteger | Level (0-100) |
userExtProfile | NSDictionary<NSString *, NSString *> | Custom fields (max 20 key-value pairs). Keys must be preconfigured in the developer console (letters/numbers, max 32 chars, unique per AppKey). Values are strings (max 256 chars). Invalid keys trigger errors. |
Example
[[RCIM sharedRCIM] updateMyUserProfile:self.profle successBlock:^{
} errorBlock:^(RCErrorCode errorCode, NSArray<NSString *> * _Nullable errorKeys) {
}];
Update Friend Information
Interface Prototype
/// Set friend info
/// - Parameter userId: User ID
/// - Parameter remark: Friend remark (max 64 chars). Pass nil/empty to clear.
/// - Parameter extProfile: Extended info
/// - Parameter successBlock: Success callback
/// - Parameter errorBlock: Failure callback
///
/// - Since: 5.16.0
- (void)setFriendInfo:(NSString *)userId
remark:(nullable NSString *)remark
extProfile:(nullable NSDictionary<NSString *, NSString*> *)extProfile
successBlock:(void (^)(void))successBlock
errorBlock:(void (^)(RCErrorCode errorCode, NSArray<NSString *> * _Nullable errorKeys))errorBlock;
Parameters
Parameter | Type | Description |
---|---|---|
userId | NSString | Target user ID |
remark | NSString | Friend remark (max 64 chars). Pass nil/empty to clear. |
extProfile | NSDictionary | Custom fields (keys must be preconfigured, max 32 chars, unique per AppKey; values max 256 chars) |
successBlock | Block | Success callback |
errorBlock | Block | Failure callback (errorCode: error code; errorKeys: invalid field keys) |
Example
[[RCIM sharedRCIM] setFriendInfo:@"userId" remark:@"name" extProfile:nil successBlock:^{
} errorBlock:^(RCErrorCode errorCode, NSArray<NSString *> * _Nullable errorKeys) {
}];
Update Group Information
Update Group Profile
Interface Prototype
/// Update group info
/// - Parameter groupInfo: Group info (groupId is required)
/// - Parameter successBlock: Success callback
/// - Parameter errorBlock: Failure callback
///
/// - Since: 5.16.0
- (void)updateGroupInfo:(RCGroupInfo *)groupInfo
successBlock:(void (^)(void))successBlock
errorBlock:(void (^)(RCErrorCode errorCode, NSArray<NSString *> * _Nullable errorKeys))errorBlock;
Parameters
Parameter | Type | Description |
---|---|---|
groupInfo | RCGroupInfo | Group info (groupId is mandatory) |
successBlock | Block | Success callback |
errorBlock | Block | Failure callback (errorCode: error code; errorKeys: error details) |
Example
[[RCIM sharedRCIM] updateGroupInfo:info
successBlock:^{
} errorBlock:^(RCErrorCode errorCode, NSArray<NSString *> * _Nullable errorKeys) {
}];
Set Group Alias
Interface Prototype
/// Set group remark
/// - Parameter groupId: Group ID
/// - Parameter remark: Group alias (max 64 chars). Pass nil/empty to remove.
/// - Parameter successBlock: Success callback
/// - Parameter errorBlock: Failure callback
///
/// - Since: 5.12.2
- (void)setGroupRemark:(NSString *)groupId
remark:(nullable NSString *)remark
success:(void (^)(void))successBlock
error:(void (^)(RCErrorCode errorCode))errorBlock;
Parameters
Parameter | Type | Description |
---|---|---|
groupId | NSString | Target group ID |
remark | NSString | Group alias (max 64 chars). Pass nil/empty to remove. |
successBlock | Block | Success callback |
errorBlock | Block | Failure callback (errorCode: error code) |
Example
[[RCIM sharedRCIM] setGroupRemark:@"groupId" remark:@"name" success:^{
} error:^(RCErrorCode errorCode) {
}];
Update Group Member Information
Interface Prototype
/// Set group member profile
/// - Parameter groupId: Group ID
/// - Parameter userId: User ID (required; supports current user ID)
/// - Parameter nickname: Nickname (max 64 chars). Pass nil/empty to remove.
/// - Parameter extra: Additional info (max 128 chars)
/// - Parameter successBlock: Success callback
/// - Parameter errorBlock: Failure callback
///
/// - Since: 5.16.0
- (void)setGroupMemberInfo:(NSString *)groupId
userId:(NSString *)userId
nickname:(nullable NSString *)nickname
extra:(nullable NSString *)extra
successBlock:(void (^)(void))successBlock
errorBlock:(void (^)(RCErrorCode errorCode, NSArray<NSString *> * _Nullable errorKeys))errorBlock;
Parameters
Parameter | Type | Description |
---|---|---|
groupId | NSString | Target group ID |
userId | NSString | User ID (required; supports current user ID) |
nickname | NSString | Nickname (max 64 chars). Pass nil/empty to remove. |
extra | NSString | Additional info (max 128 chars) |
successBlock | Block | Success callback |
errorBlock | Block | Failure callback (errorCode: error code; errorKeys: invalid fields) |
Example
[[RCIM sharedRCIM] setGroupMemberInfo:@"groupId" userId:@"userId" nickname:@"name" extra:nil
successBlock:^{
} errorBlock:^(RCErrorCode errorCode, NSArray<NSString *> * _Nullable errorKeys) {
}];