Skip to main content

Profile and relationship management

About profile and relationship data

Chat UI SDK uses profile and relationship data to display users, friends, groups, group members, and related management pages.

By default, Chat UI SDK uses the Nexconn-hosted data source for profile and relationship data. In this mode, the SDK can retrieve and update hosted profiles, friend relationships, groups, and group member information through Nexconn APIs.

If your app does not want to host profile data in Nexconn, switch NCUserInfoManager to DataSourceType.INFO_PROVIDER and provide user, group, and group member display data from your app. For details, see User information provider delegate method.

When the hosted data source is used, the SDK displays profiles in the following priority: message-embedded information first, then hosted profiles. Profile cache remains valid throughout the application lifecycle.

Use Nexconn-hosted data

Java
NCUserInfoManager.getInstance()
.setDataSourceType(NCUserInfoManager.DataSourceType.INFO_MANAGEMENT);

DataSourceType.INFO_MANAGEMENT is the default data source. You only need to set it explicitly if your app switches data sources at runtime or if you want to make the data source selection clear in your initialization code.

Use app-managed data

Java
NCUserInfoManager.getInstance()
.setDataSourceType(NCUserInfoManager.DataSourceType.INFO_PROVIDER);

Use this mode when your app server or client is responsible for maintaining profile data and you do not want to store profile data in Nexconn. In this mode, provide display data through NCUserInfoManager and UserDataProvider.

Update hosted information with Nexconn APIs

When you use the hosted data source, use NCEngine.userModule and GroupChannel public APIs to update profiles.

Update current user profile

kotlin
val profile = UserProfile(
userId = NCEngine.getCurrentUserId() ?: return,
name = "New nickname"
)

NCEngine.userModule.updateMyUserProfile(profile) { errorKeys, error ->
// error == null indicates success
}

Update friend profile (remark and extension fields)

kotlin
val params = SetFriendInfoParams("user_001").apply {
remark = "Coworker"
extProfile = mapOf("department" to "R&D")
}

NCEngine.userModule.setFriendInfo(params) { errorKeys, error ->
// error == null indicates success
}

Update group profile

kotlin
val group = GroupChannel("group_001")
val params = UpdateGroupInfoParams().apply {
groupName = "Project group"
}

group.updateInfo(params) { errorKeys, error ->
// error == null indicates success
}

Update group member profile

kotlin
val group = GroupChannel("group_001")
val params = SetGroupMemberInfoParams(
userId = "user_001",
nickname = "Frontend-Wang",
extra = ""
)

group.setMemberInfo(params) { errorKeys, error ->
// error == null indicates success
}
tip

Nexconn-hosted profile data is primarily used to synchronize and display channel-related fields such as nicknames, remarks, and avatars. We recommend that your business server maintains business extension fields.