Skip to main content

User profiles

This guide explains how to manage user profiles with the Nexconn SDK for Android, including setting, querying, subscribing, and listening for profile changes.

Manage user profiles

You can update your own profile, retrieve your profile, or query profiles for multiple users in bulk.

Update your profile

Use NCEngine.userModule.updateMyUserProfile() with UserProfile to update the current user's profile.

tip

By default, profile data is not subject to content moderation. To enable moderation, configure the relevant profile moderation option in the Console under Chat > Chat settings > Security & Moderation.

Parameters (UserProfile)

PropertyTypeDescription
nameString?Nickname. Max 32 characters.
portraitUriString?Avatar URL. Max 128 characters.
emailString?Email. Max 128 characters.
birthdayString?Birthday. Max 32 characters.
genderInt?Gender: 0 = unknown, 1 = male, 2 = female.
locationString?Location. Max 32 characters.
roleInt?Role. Range: 0–100.
levelInt?Level. Range: 0–100.
kotlin
val profile = UserProfile(
name = "New Nickname",
portraitUri = "https://example.com/avatar.png",
gender = 1 // 1 = male
)

NCEngine.userModule.updateMyUserProfile(profile) { errorKeys, error ->
if (error == null) {
// Updated successfully
} else {
// Failed — errorKeys contains keys that failed
}
}

Get your profile

Use NCEngine.userModule.getMyUserProfile() to retrieve the current user's profile.

kotlin
NCEngine.userModule.getMyUserProfile { profile, error ->
if (error == null && profile != null) {
println("Name: ${profile.name}, Avatar: ${profile.portraitUri}")
}
}

Get profiles in bulk

Use NCEngine.userModule.getUserProfiles() to retrieve profiles for specific users by userId.

tip

You can query up to 20 users per call.

kotlin
val userIds = listOf("user1", "user2", "user3")

NCEngine.userModule.getUserProfiles(userIds) { profiles, error ->
if (error == null && profiles != null) {
profiles.forEach { profile ->
println("User: ${profile.userId}, Name: ${profile.name}")
}
}
}

Manage profile visibility

The Nexconn SDK provides APIs to set and retrieve user-level profile visibility using the UserProfileVisibility enum.

UserProfileVisibility enum values:

ValueDescription
UserProfileVisibility.NOT_SETNot set. Follows the app-level setting (default).
UserProfileVisibility.INVISIBLEHidden. No one can view the user's profile (except name and avatar).
UserProfileVisibility.EVERYONEPublic. Any user in the app can view the profile.
UserProfileVisibility.FRIEND_VISIBLEFriends only. Only users on the friend list can view the profile.

Visibility behavior

The default app-level profile visibility is Hidden. The default user-level visibility is Not set. When both are at their default values, other users can only see the user's name and avatar.

App-level visibilityUser-level visibilityResult
Hidden, Friends only, or PublicNot setApp-level setting applies
Hidden, Friends only, or PublicSet to Hidden, Friends only, or PublicUser-level setting applies

Set profile visibility

Use NCEngine.userModule.updateMyUserProfileVisibility() to set your profile visibility.

kotlin
NCEngine.userModule.updateMyUserProfileVisibility(UserProfileVisibility.EVERYONE) { error ->
if (error == null) {
// Visibility updated
}
}

Get profile visibility

Use NCEngine.userModule.getMyUserProfileVisibility() to retrieve your current profile visibility setting.

kotlin
NCEngine.userModule.getMyUserProfileVisibility { visibility, error ->
if (error == null && visibility != null) {
println("Current visibility: $visibility")
}
}

Subscribe to profile and visibility changes

Listen for subscription events

To receive profile change notifications, use NCEngine.addUserHandler().

Handle events based on the SubscribeType. For user profile events, the type is SubscribeType.USER_PROFILE.

kotlin
NCEngine.addUserHandler("PROFILE_HANDLER", object : UserHandler {
override fun onSubscriptionChanged(event: SubscriptionChangedEvent) {
if (event.subscribeType == SubscribeType.USER_PROFILE) {
event.events.forEach { info ->
println("Profile changed for user: ${info.userId}")
}
}
}

override fun onSubscriptionSyncCompleted(event: SubscriptionSyncCompletedEvent) {
if (event.subscribeType == SubscribeType.USER_PROFILE) {
// Profile subscription sync complete
}
}

override fun onSubscriptionChangedOnOtherDevices(event: SubscriptionChangedOnOtherDevicesEvent) {
event.events.forEach { info ->
println("Subscription changed on other device: ${info.userId}")
}
}
})

Subscribe to profile changes

Use NCEngine.userModule.subscribeEvent() with SubscribeEventParams to track profile and visibility changes for other users.

tip
  • Up to 200 users per subscription call.
  • Maximum total subscriptions: 1,000 users.
  • Each user can be subscribed to by up to 5,000 users.
  • Subscription duration: 60 to 2,592,000 seconds.
kotlin
val params = SubscribeEventParams(
subscribeType = SubscribeType.USER_PROFILE,
expiry = 180000,
userIds = listOf("user1", "user2", "user3")
)

NCEngine.userModule.subscribeEvent(params) { failedIds, error ->
if (error == null) {
// Subscribed successfully
} else {
// failedIds contains user IDs that failed
}
}

Unsubscribe from profile changes

Use NCEngine.userModule.unsubscribeEvent() to stop tracking profile changes. You can unsubscribe up to 200 users per call.

kotlin
val params = UnsubscribeEventParams(
subscribeType = SubscribeType.USER_PROFILE,
userIds = listOf("user1", "user2", "user3")
)

NCEngine.userModule.unsubscribeEvent(params) { failedIds, error ->
if (error == null) {
// Unsubscribed successfully
}
}

Query subscription status for specific users

Use NCEngine.userModule.getSubscribeEvent() to check the profile subscription status of specific users. You can query up to 200 users at a time.

kotlin
val params = GetSubscribeEventParams(
subscribeType = SubscribeType.USER_PROFILE,
userIds = listOf("user1", "user2", "user3")
)

NCEngine.userModule.getSubscribeEvent(params) { subscribeInfoList, error ->
if (error == null && subscribeInfoList != null) {
subscribeInfoList.forEach { info ->
println("Subscribed user: ${info.userId}, expires: ${info.expiry}")
}
}
}

List profile subscriptions (paginated)

Use NCEngine.userModule.createSubscribeQuery() with SubscribeQueryParams to retrieve all profile subscription events with pagination.

kotlin
val params = SubscribeQueryParams(SubscribeType.USER_PROFILE).apply {
pageSize = 20
}

val query = NCEngine.userModule.createSubscribeQuery(params)

query.loadNextPage { page, error ->
if (error == null && page != null) {
page.data.forEach { info ->
println("Subscribed user: ${info.userId}")
}
if (page.hasMore) {
// Fetch next page
}
}
}