Browse SDKs · uni-app / uni-app x
Platform
SDKsuni-app / uni-app x

Join a group

Submit an application to join a group, or join directly if verification is disabled.

Copy

Invoke joinGroup() to request membership in a specified group. Whether approval is required depends on the group's needVerification setting, while joinSource records how the user discovered and joined the group.

Parameters

ParameterTypeRequiredDescription
groupIDstringYesTarget group identifier.
reqMsgstringYesApplication greeting or note; pass an empty string if omitted.
joinSourceOpenIMGroupJoinSourceYesChannel through which the user joined or applied.
exstringNoOptional business extension string.
Enum constantNumeric valueDescription
OpenIMGroupJoinSourceAdmin1Added by an administrator; typically reserved for administrative workflows.
OpenIMGroupJoinSourceInvitation2Joined via direct invitation.
OpenIMGroupJoinSourceSearch3Joined via group search.
OpenIMGroupJoinSourceQRCode4Joined by scanning a group QR code.

Code example

import {
  OpenIMGroupJoinSourceSearch,
  joinGroup,
} from '@/uni_modules/unix-openim-sdk'

await joinGroup({
  groupID: groupID,
  reqMsg: 'Requesting to join the project team',
  joinSource: OpenIMGroupJoinSourceSearch,
})

Return value

The Promise resolves with void once the join request is submitted to OpenIMServer.

State changes after the call

A resolved Promise confirms that the request reached the server. If the group enforces verification, resolution does not mean the user is an active member; membership is established only after an administrator approves the application. When approved, the client receives onJoinedGroupAdded and adds the group indexed by groupID to its joined group list. For event handling, see Group overview.

Even if verification is disabled, rely on incoming events or re-querying Check group membership to confirm membership before unlocking messaging features.