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:
[NCChatUI shared].currentDataSourceType = NCDataSourceTypeInfoProvider;
- 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
/// 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:
| Property | 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: Chat SDK doesn't support setting this field. |
| NSString | Email (max 128 chars) | |
| birthday | NSString | Birthday (max 32 chars) |
| gender | NSInteger | Gender |
| location | NSString | Location (max 32 chars) |
| role | NSUInteger | Role (0-100) |
| level | NSUInteger | Level (0-100) |
| userExtProfile | NSDictionary<NSString *, NSString *> | Custom extended info (max 20 key-value pairs). Keys must be preconfigured in developer console:
|
Example
[[NCChatUI shared] updateMyUserProfile:self.profle completion:^(NSArray<NSString *> * _Nullable errorKeys, NCError * _Nullable error) {
}];
Update friend information
Interface prototype
/// 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
| Parameter | Type | Description |
|---|---|---|
| userId | NSString | Target user ID |
| remark | NSString | Friend remark (max 64 chars). Pass nil/empty to clear. |
| extProfile | NSDictionary | Extended info (keys must be preconfigured in developer console) |
| completion | Block | Callback. Returns (nil, nil) on success, or errorKeys and NCError on failure. |
Example
[[NCChatUI shared] setFriendInfo:@"userId" remark:@"name" extProfile:nil completion:^(NSArray<NSString *> * _Nullable errorKeys, NCError * _Nullable error) {
}];
Update group information
Interface prototype
/// 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
| Parameter | Type | Description |
|---|---|---|
| groupInfo | NCGroupInfo | Group info (groupId required) |
| completion | Block | Callback. Returns (nil, nil) on success, or errorKeys and NCError on failure. |
Example
[[NCChatUI shared] updateGroupInfo:info
completion:^(NSArray<NSString *> * _Nullable errorKeys, NCError * _Nullable error) {
}];
Update group member information
Interface prototype
/// 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
| Parameter | Type | Description |
|---|---|---|
| groupId | NSString | Target group ID |
| userId | NSString | User ID (required) |
| nickname | NSString | Nickname (max 64 chars). Pass nil/empty to remove. |
| extra | NSString | Extra info (max 128 chars) |
| completion | Block | Callback. Returns (nil, nil) on success, or errorKeys and NCError on failure. |
Example
[[NCChatUI shared] setGroupMemberInfo:@"groupId" userId:@"userId" nickname:@"name" extra:nil
completion:^(NSArray<NSString *> * _Nullable errorKeys, NCError * _Nullable error) {
}];