Skip to main content

User Profile Hosting Overview

tip

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;
tip
  • 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:

AttributeTypeDescription
nameNSStringNickname (max 32 chars)
portraitUriNSStringAvatar URL (max 128 chars)
uniqueIdNSStringUser app ID (letters/numbers, max 32 chars). Note: Client SDK cannot set this field.
emailNSStringEmail (max 128 chars)
birthdayNSStringBirthday (max 32 chars)
genderRCUserGenderGender
locationNSStringLocation (max 32 chars)
roleNSUIntegerRole (0-100)
levelNSUIntegerLevel (0-100)
userExtProfileNSDictionary<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

ParameterTypeDescription
userIdNSStringTarget user ID
remarkNSStringFriend remark (max 64 chars). Pass nil/empty to clear.
extProfileNSDictionaryCustom fields (keys must be preconfigured, max 32 chars, unique per AppKey; values max 256 chars)
successBlockBlockSuccess callback
errorBlockBlockFailure 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

ParameterTypeDescription
groupInfoRCGroupInfoGroup info (groupId is mandatory)
successBlockBlockSuccess callback
errorBlockBlockFailure 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

ParameterTypeDescription
groupIdNSStringTarget group ID
remarkNSStringGroup alias (max 64 chars). Pass nil/empty to remove.
successBlockBlockSuccess callback
errorBlockBlockFailure 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

ParameterTypeDescription
groupIdNSStringTarget group ID
userIdNSStringUser ID (required; supports current user ID)
nicknameNSStringNickname (max 64 chars). Pass nil/empty to remove.
extraNSStringAdditional info (max 128 chars)
successBlockBlockSuccess callback
errorBlockBlockFailure 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) {
}];