Skip to main content

Information management overview

Information management introduction

Chat UI uses information management by default 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.

In information management mode, Chat UI does not retrieve user information through app-side information providers. The channel page and channel list 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 source mode

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

currentDataSourceType defaults to NCDataSourceTypeInfoManagement. No extra configuration is required if your app uses Chat UI's managed information service.

If your app wants to provide user, group, and group member information through the user information provider delegate approach, switch to information provider mode:

Objective C
[NCChatUI shared].currentDataSourceType = NCDataSourceTypeInfoProvider;
tip
  • Configure the information source mode after initializing Chat UI but before connecting to Chat.
  • In the default 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 channel lists and channel pages. For other information, directly use Chat information management interfaces.

Updating information

In the default 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: Chat 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) {
}];