Skip to main content

Information management overview

Information management introduction

Chat UI supports switching information management modes to display user and group information in channel pages and channel lists. It also provides information management pages including user profiles, friend pages, and group profiles.

After switching to information management mode, Chat UI no longer retrieves user information through information providers. The channel page and channel list will first display user information carried in message bodies, then fall back to managed information.

Chat UI does not update information in channel lists in real time. The latest information is only fetched when entering relevant interfaces.

Information management toggle

The information management service is enabled by default and ready for immediate use.

By default, Chat UI SDK uses the user information provider delegate approach to display user and group information in channel pages and channel lists. To switch to information management mode, manually configure:

Objective C
[[NCChatUI shared] setCurrentDataSourceType:NCDataSourceTypeInfoManagement];
tip
  • Switch the user information provider mode after initializing Chat UI SDK but before connecting to IM.
  • After switching to information management mode, user and group information in channel lists and channel pages comes from Chat UI's information management interfaces. Retrieved information is cached in memory and maintained throughout the application lifecycle.
  • To update user or group information, you must use the update interfaces in NCChatUI.
  • The in-memory user information is primarily used for displaying basic details (names, remarks, avatars) in Chat UI SDK channel lists and channel pages. For other information, directly use the Chat SDK layer's information management interfaces.

Updating information

After switching to information management mode, use these update interfaces in NCChatUI:

Update current user information

Interface prototype

Objective C
/// Update current user's information
///
/// - Parameter profile: User profile
/// - Parameter completion: Update completion callback
- (void)updateMyUserProfile:(NCUserProfile *)profile
completion:(nullable void (^)(NSArray<NSString *> * _Nullable errorKeys, NCError * _Nullable error))completion;

Parameters

NCUserProfile properties:

PropertyTypeDescription
nameNSStringNickname (max 32 chars)
portraitUriNSStringAvatar URL (max 128 chars)
uniqueIdNSStringUser app ID (letters, numbers, max 32 chars). Note: Client SDK doesn't support setting this field.
emailNSStringEmail (max 128 chars)
birthdayNSStringBirthday (max 32 chars)
genderNSIntegerGender
locationNSStringLocation (max 32 chars)
roleNSUIntegerRole (0-100)
levelNSUIntegerLevel (0-100)
userExtProfileNSDictionary<NSString *, NSString *>Custom extended info (max 20 key-value pairs). Keys must be preconfigured in developer console:
  1. Key: Letters, numbers (max 32 chars), unique per AppKey
  2. Value: String (max 256 chars)

Example

Objective C
[[NCChatUI shared] updateMyUserProfile:self.profle completion:^(NSArray<NSString *> * _Nullable errorKeys, NCError * _Nullable error) {
}];

Update friend information

Interface prototype

Objective C
/// Set friend information
/// - Parameter userId: User ID
/// - Parameter remark: Friend remark (max 64 chars). Pass nil or empty string to clear remark.
/// - Parameter extProfile: Extended info
/// - Parameter completion: Completion callback
- (void)setFriendInfo:(NSString *)userId
remark:(nullable NSString *)remark
extProfile:(nullable NSDictionary<NSString *, NSString*> *)extProfile
completion:(nullable void (^)(NSArray<NSString *> * _Nullable errorKeys, NCError * _Nullable error))completion;

Parameters

ParameterTypeDescription
userIdNSStringTarget user ID
remarkNSStringFriend remark (max 64 chars). Pass nil/empty to clear.
extProfileNSDictionaryExtended info (keys must be preconfigured in developer console)
completionBlockCallback. Returns (nil, nil) on success, or errorKeys and NCError on failure.

Example

Objective C
[[NCChatUI shared] setFriendInfo:@"userId" remark:@"name" extProfile:nil completion:^(NSArray<NSString *> * _Nullable errorKeys, NCError * _Nullable error) {
}];

Update group information

Interface prototype

Objective C
/// Update group information
/// - Parameter groupInfo: Group info (groupId is required)
/// - Parameter completion: Completion callback
- (void)updateGroupInfo:(NCGroupInfo *)groupInfo
completion:(nullable void (^)(NSArray<NSString *> * _Nullable errorKeys, NCError * _Nullable error))completion NS_SWIFT_NAME(updateGroupInfo(_:completion:));

Parameters

ParameterTypeDescription
groupInfoNCGroupInfoGroup info (groupId required)
completionBlockCallback. Returns (nil, nil) on success, or errorKeys and NCError on failure.

Example

Objective C
[[NCChatUI shared] updateGroupInfo:info
completion:^(NSArray<NSString *> * _Nullable errorKeys, NCError * _Nullable error) {
}];

Update group member information

Interface prototype

Objective C
/// Set group member information
/// - Parameter groupId: Group ID
/// - Parameter userId: User ID (required, can be current user)
/// - Parameter nickname: Nickname (max 64 chars). Pass nil/empty to remove.
/// - Parameter extra: Extra info (max 128 chars)
/// - Parameter completion: Completion callback
- (void)setGroupMemberInfo:(NSString *)groupId
userId:(NSString *)userId
nickname:(nullable NSString *)nickname
extra:(nullable NSString *)extra
completion:(nullable void (^)(NSArray<NSString *> * _Nullable errorKeys, NCError * _Nullable error))completion;

Parameters

ParameterTypeDescription
groupIdNSStringTarget group ID
userIdNSStringUser ID (required)
nicknameNSStringNickname (max 64 chars). Pass nil/empty to remove.
extraNSStringExtra info (max 128 chars)
completionBlockCallback. Returns (nil, nil) on success, or errorKeys and NCError on failure.

Example

Objective C
[[NCChatUI shared] setGroupMemberInfo:@"groupId" userId:@"userId" nickname:@"name" extra:nil
completion:^(NSArray<NSString *> * _Nullable errorKeys, NCError * _Nullable error) {
}];