Skip to main content

Managing membership requests

This guide covers how to join groups, invite users, accept or reject join requests, and manage membership approvals using the Nexconn SDK.

Joining a group

Join a group directly

Use groupChannel.join() to request to join a group. The result depends on the group's joinPermission setting:

  1. Owner/admin approval required: The callback returns error code 25424, indicating the request is pending. Both the requester and the owner/admin receive an onGroupApplicationEvent callback.
  2. No approval required: The callback returns null error (success), indicating the user has joined. All members receive an onGroupOperation callback with type Join.
kotlin
val channel = GroupChannel("groupId1")

channel.join { code, error ->
if (error == null) {
// Joined successfully (code == 0)
} else if (error.code == 25424) {
// Join request pending approval
} else {
// Request failed
}
}

Invite users to a group

Use groupChannel.inviteUsers() to invite users. Only users with the invitePermission role can use this API.

kotlin
val channel = GroupChannel("groupId1")
val userIds = listOf("userId1", "userId2", "userId3")

channel.inviteUsers(userIds) { code, error ->
if (error == null) {
// Invitation sent or user joined directly (code == 0)
} else if (error.code == 25424) {
// Approval required from owner/admin
} else if (error.code == 25427) {
// Invitee needs to accept
} else {
// Invitation failed
}
}

The invitation behavior depends on three factors:

  1. Join permission (joinPermission): Whether owner/admin approval is required.
  2. Inviter role (role): Whether the inviter is an owner/admin or a regular member.
  3. Invitee handling (inviteHandlePermission): Whether invitees must accept the invitation.

Invitation flow rules

tip

The table below assumes invitePermission is set to Everyone (all members can invite).

Join PermissionInviter RoleInvitee ApprovalFlow
Owner/admin approval requiredRegular memberRequiredFlow A
Owner/admin approval requiredRegular memberNot requiredFlow B
Owner/admin approval requiredOwner or adminRequiredFlow C
Owner/admin approval requiredOwner or adminNot requiredFlow D
No approval requiredAny roleRequiredFlow C
No approval requiredAny roleNot requiredFlow D
Flow a

Regular member invites, owner/admin approval required, invitee approval required.

  1. Invitation sent → error code 25424. The inviter and owner/admin receive onGroupApplicationEvent.
  2. Owner/admin approves → inviter, owner/admin, and invitee receive onGroupApplicationEvent.
  3. Invitee accepts → all members receive onGroupOperation with type Join.
Flow b

Regular member invites, owner/admin approval required, invitee approval not required.

  1. Invitation sent → error code 25424. The inviter and owner/admin receive onGroupApplicationEvent.
  2. Owner/admin approves → invitee joins automatically. All members receive onGroupOperation with type Join.
Flow c

Any role invites, no owner/admin approval needed, invitee approval required.

  1. Invitation sent → error code 25427. The inviter and invitee receive onGroupApplicationEvent.
  2. Invitee accepts → all members receive onGroupOperation with type Join.
Flow d

No approval from anyone is required.

  1. Invitation sent → success (null error). The invitee joins immediately. All members receive onGroupOperation with type Join.

Invitee handling

Accept an invitation

Use channel.acceptInvite(inviterId) (instance method) to accept a group invitation.

kotlin
val channel = GroupChannel("groupId1")

channel.acceptInvite("inviterUserId") { error ->
if (error == null) {
// Accepted
} else {
// Failed
}
}

Reject an invitation

Use channel.refuseInvite(RefuseGroupInviteParams) (instance method) to decline a group invitation.

kotlin
val channel = GroupChannel("groupId1")

val params = RefuseGroupInviteParams(inviterId = "inviterUserId").apply {
reason = "Not interested"
}

channel.refuseInvite(params) { error ->
if (error == null) {
// Rejected
}
}

Owner/Admin handling

Membership requests expire after 7 days. The server stores request data for up to 7 days.

Approve a request

Use channel.acceptApplication(AcceptGroupApplicationParams) (instance method) to approve a join request.

  • For a direct join request: pass the applicant's ID as userId; leave inviterId as null.
  • For an invitation request: pass both userId and inviterId.
kotlin
val channel = GroupChannel("groupId1")

val params = AcceptGroupApplicationParams(applicantId = "applicantUserId").apply {
inviterId = "inviterUserId" // null for direct join requests
}

channel.acceptApplication(params) { code, error ->
if (error == null) {
// Approved
} else if (error.code == 25427) {
// Invitee needs to accept
}
}

Reject a request

Use channel.refuseApplication(RefuseGroupApplicationParams) (instance method) to reject a join request.

kotlin
val channel = GroupChannel("groupId1")

val params = RefuseGroupApplicationParams(applicantId = "applicantUserId").apply {
inviterId = "inviterUserId"
reason = "Group is full"
}

channel.refuseApplication(params) { error ->
if (error == null) {
// Rejected
}
}

Get membership request list (paginated)

Use GroupChannel.createGroupApplicationsQuery() with GroupApplicationsQueryParams to retrieve membership requests with pagination. Requests expire after 7 days.

kotlin
val params = GroupApplicationsQueryParams().apply {
pageSize = 20
isAscending = false
}

val query = GroupChannel.createGroupApplicationsQuery(params)

query.loadNextPage { page, error ->
if (error == null && page != null) {
page.data?.forEach { app ->
println("Applicant: ${app.joinMemberInfo?.userId}, Group: ${app.groupId}")
}
if (query.hasMore) {
query.loadNextPage { nextPage, nextError ->
// Handle next page
}
}
}
}