inviteUserToGroup
Function Introduction
Description
Invite users to the group.
Note
The result of the invitation to join the group is determined by the caller's identity and the group verification option.
Related Callbacks: onJoinedGroupAdded onGroupMemberAdded onGroupApplicationAdded
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<List<GroupInviteResult>> inviteUserToGroup({
required String groupID,
required List<String> userIDList,
String? reason,
String? operationID,
})
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
groupID | String | Yes | Group ID |
reason | String | Yes | Invitation message |
userIDList | List<String> | Yes | List of userIDs to be invited |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
~ | List<GroupInviteResult> | Success return |
GroupInviteResult
Field Name | Field Type | Description |
---|---|---|
userID | String | User ID |
result | Int | Invitation result |
Code Example
List<GroupInviteResult> list = await OpenIM.iMManager.groupManager.inviteUserToGroup(
groupID: '',
userIDList: [],
);
// todo
Function Prototype
- (void)inviteUserToGroup:(NSString *)groupID
reason:(NSString *)reason
usersID:(NSArray <NSString *> *)usersID
onSuccess:(nullable OIMSimpleResultsCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
groupID | NSString | Yes | Group ID |
reason | NSString | Yes | Invitation message |
usersID | NSArray <NSString *> | Yes | List of userIDs to be invited |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
onSuccess | NSArray<OIMSimpleResultInfo * > | Success return |
onFailure | OIMFailureCallback | Failure return |
OIMSimpleResultInfo
Field Name | Field Type | Description |
---|---|---|
userID | NSString | User ID |
result | NSInteger | Invitation result |
Code Example
[OIMManager.manager inviteUserToGroup:@""
reason:@""
usersID:@[]
onSuccess:^(NSArray<OIMSimpleResultInfo *> * _Nullable results) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void inviteUserToGroup(OnBase<List<GroupInviteResult>> callBack, String groupId, List<String> uidList, String reason)
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
callBack | OnBase<List<ResultInfo>> | Yes | Callback interface |
groupId | String | Yes | Group ID |
reason | String | Yes | Invitation message |
uidList | List<String> | Yes | List of invitees' IDs |
Return Result
Code Example
OpenIMClient.getInstance().groupManager.inviteUserToGroup(new OnBase<List<ResultInfo>>() {
@Override
public void onError(int code, String error) {
}
@Override
public void onSuccess(List<GroupInviteResult> data) {
}
},groupId,uidList,reason)
Function Prototype
IMSDK.inviteUserToGroup({
groupID: string;
reason: string;
userIDList: string[];
}, operationID?: string): Promise<WsResponse>
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
groupID | string | Yes | Group ID |
reason | string | Yes | Invitation message |
userIDList | string[] | Yes | List of userIDs to be invited |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse> | Success callback |
Promise.catch() | Promise<WsResponse> | Failure callback |
Code Example
import { getSDK } from '@openim/wasm-client-sdk';
const IMSDK = getSDK();
// use in electron with ffi
// import { getWithRenderProcess } from '@openim/electron-client-sdk/lib/render';
// const { instance: IMSDK } = getWithRenderProcess();
// use in mini program
// import { OpenIMSDK } from 'open-im-sdk';
// const IMSDK = new OpenIMSDK();
IMSDK.inviteUserToGroup({
groupID: '',
reason: '',
userIDList: ['userID'],
})
.then(() => {
// Call succeeded
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
IMSDK.asyncApi('inviteUserToGroup', operationID: string, {
groupID: string;
reason: string;
userIDList: string[];
}): Promise<void>
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, used for troubleshooting, should be unique. Recommended to use the current time combined with a random number |
groupID | string | Yes | Group ID |
reason | string | Yes | Invitation message |
userIDList | string[] | Yes | List of userIDs to be invited |
Return Result
With the
openim-uniapp-polyfill
package, functions are made into Promises. When calling, usethen
andcatch
to determine and handle success and failure callbacks.
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<void> | Success callback |
Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('inviteUserToGroup', IMSDK.uuid(), {
groupID: '',
reason: '',
userIDList: ['userID'],
})
.then(() => {
// Call succeeded
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDKRN.inviteUserToGroup({
groupID: string,
reason: string,
userIDList: string[],
}, operationID: string): Promise<void>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
groupID | string | Yes | Group ID |
reason | string | Yes | Invitation message |
userIDList | string[] | Yes | List of userIDs to be invited |
operationID | string | Yes | Operation ID, used for problem location, keep unique, suggest using current time and random number |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<void> | Callback on successful call |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.inviteUserToGroup({
groupID: '',
reason: '',
userIDList: ['userID'],
}, 'operationID')
.then(() => {
// Call succeeded
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
public static void InviteUserToGroup(OnBase<bool> cb, string groupId, string reason, string[] userIdList)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | OnBase | Yes | Callback |
groupId | string | Yes | Group ID |
reason | sting | Yes | Invitation message |
userIdList | string[] | Yes | Array of userIDs to be invited |
Return Result
Code Example
IMSDK.InviteUserToGroup((suc,errCode,errMsg)=>{
},groupId,uidList,reason);