群组相关
更新时间: 2025/08/04 11:03:44
网易云信即时通讯 SDK(NetEase IM SDK,以下简称 NIM SDK)提供了高级群和超大群两种形式的群组功能,支持用户创建、加入、退出、转让、修改、查询、解散群组,拥有完善的管理功能。
本文介绍群组管理相关 API。更多群组相关功能请参考 群组概述。
支持平台
本文内容适用的开发平台或框架如下表所示:
Android | iOS | macOS/Windows | Web/uni-app/小程序 | Node.js/Electron | HarmonyOS |
---|---|---|---|---|---|
✔️️ | ✔️️ | ✔️️ | ✔️️ | ✔️️ | ✔️️ |
API 概览
群组监听
API | 说明 | 起始版本 |
---|---|---|
addTeamListener | 注册群组相关监听器 | v10.2.0 |
removeTeamListener | 移除群组相关监听器 | v10.2.0 |
API | 说明 | 起始版本 |
---|---|---|
on("EventName") | 注册群组相关监听 | v10.2.0(对应 HarmonyOS v0.5.0) |
off("EventName") | 取消注册群组相关监听 | v10.2.0(对应 HarmonyOS v0.5.0) |
群组操作
API | 说明 | 起始版本 |
---|---|---|
createTeam | 创建一个群组 | v10.2.0(对应 HarmonyOS v0.5.0) |
updateTeamInfo | 修改群组信息 | v10.2.0(对应 HarmonyOS v0.5.0) |
leaveTeam | 退出群组 | v10.2.0(对应 HarmonyOS v0.5.0) |
getTeamInfo | 获取群组信息 | v10.2.0(对应 HarmonyOS v0.5.0) |
getTeamInfoByIds | 根据群组 ID 批量获取群组信息 | v10.2.0(对应 HarmonyOS v0.5.0) |
dismissTeam | 解散群组 | v10.2.0(对应 HarmonyOS v0.5.0) |
inviteMember | 邀请成员加入群组 | v10.2.0(对应 HarmonyOS v0.5.0) |
acceptInvitation | 接受入群邀请 | v10.2.0(对应 HarmonyOS v0.5.0) |
rejectInvitation | 拒绝入群邀请 | v10.2.0(对应 HarmonyOS v0.5.0) |
kickMember | 踢出群成员 | v10.2.0(对应 HarmonyOS v0.5.0) |
applyJoinTeam | 申请加入群组 | v10.2.0(对应 HarmonyOS v0.5.0) |
acceptJoinApplication | 同意入群申请 | v10.2.0(对应 HarmonyOS v0.5.0) |
rejectJoinApplication | 拒绝入群申请 | v10.2.0(对应 HarmonyOS v0.5.0) |
updateTeamMemberRole | 修改群成员角色 | v10.2.0(对应 HarmonyOS v0.5.0) |
transferTeamOwner | 转让群主身份 | v10.2.0(对应 HarmonyOS v0.5.0) |
updateSelfTeamMemberInfo | 修改自己的群成员信息 | v10.2.0(对应 HarmonyOS v0.5.0) |
updateTeamMemberNick | 修改群成员昵称 | v10.2.0(对应 HarmonyOS v0.5.0) |
updateTeamMemberNickEx | 修改群成员昵称updateTeamMemberNick 接口,支持在更新时设置 antispamConfig 字段,配置是否通过反垃圾审核 |
v10.9.30 |
setTeamChatBannedMode | 设置群组禁言模式 | v10.2.0(对应 HarmonyOS v0.5.0) |
setTeamMemberChatBannedStatus | 设置群成员聊天禁言状态 | v10.2.0(对应 HarmonyOS v0.5.0) |
getJoinedTeamList | 获取当前已经加入的群组列表 | v10.2.0(对应 HarmonyOS v0.5.0) |
getJoinedTeamCount | 获取当前已经加入的群组数量 | v10.2.0(对应 HarmonyOS v0.5.0) |
getTeamMemberList | 分页获取群组成员列表 | v10.2.0(对应 HarmonyOS v0.5.0) |
getTeamMemberListByIds | 根据账号批量获取群组成员列表 | v10.2.0(对应 HarmonyOS v0.5.0) |
getTeamMemberInvitor | 根据账号获取群组成员邀请人 | v10.2.0(对应 HarmonyOS v0.5.0) |
getTeamJoinActionInfoList | 获取入群操作相关信息列表 | v10.2.0(对应 HarmonyOS v0.5.0) |
searchTeamByKeyword | 根据关键字搜索群信息(包括高级群和超大群) | v10.3.0(对应 HarmonyOS v10.0.0) |
searchTeamMembers | 根据关键字搜索群成员(包括高级群和超大群) | v10.3.0(对应 HarmonyOS v10.0.0) |
addTeamMembersFollow | 添加特别关注的群成员列表 | v10.5.0(对应 HarmonyOS v10.9.20) |
removeTeamMembersFollow | 移除特别关注的群成员列表 | v10.5.0(对应 HarmonyOS v10.9.20) |
clearAllTeamJoinActionInfo | 清空所有入群申请 | v10.6.0 |
deleteTeamJoinActionInfo | 删除指定的入群申请 | v10.6.0 |
inviteMemberEx | 邀请成员加入群组 | v10.8.10 |
getJoinedTeamMembers | 查询自己加入的群组的成员信息列表 | v10.9.10 |
setTeamJoinActionInfoRead | 设置群申请已读 | |
getTeamJoinActionInfoUnreadCount | 获取未读的群申请/邀请数量 |
接口类
V2NIMTeamService
类提供群组相关接口,包括注册群组监听,创建、修改、退出、解散、加入群组、获取群组相关信息等接口。
addTeamListener
接口描述
注册群组相关监听器。
注册成功后,当事件发生时,SDK 会返回对应的回调。
-
建议在初始化后调用该方法。
-
全局只需注册一次。
-
该方法为同步。
参数说明
Javavoid addTeamListener(V2NIMTeamListener listener);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
listener |
V2NIMTeamListener |
是 | 群组相关监听器。 |
Objective-C- (void)addTeamListener:(id<V2NIMTeamListener>)listener;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
listener |
V2NIMTeamListener |
是 | 群组相关监听器。 |
C++virtual void addTeamListener(V2NIMTeamListener listener) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
listener |
V2NIMTeamListener |
是 | 群组相关监听器。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
V2NIMTeamListener listener = new V2NIMTeamListener() {
@Override
public void onSyncStarted() {
// 开始同步群组信息
}
@Override
public void onSyncFinished() {
// 同步群组信息完成
}
@Override
public void onSyncFailed(V2NIMError error) {
// 同步群组信息失败
}
@Override
public void onTeamCreated(V2NIMTeam team) {
// 创建群组成功
}
@Override
public void onTeamDismissed(V2NIMTeam team) {
// 解散群组成功
}
@Override
public void onTeamJoined(V2NIMTeam team) {
// 加入群组成功
}
@Override
public void onTeamLeft(V2NIMTeam team, boolean isKicked) {
// 离开群组成功
}
@Override
public void onTeamInfoUpdated(V2NIMTeam team) {
// 群组信息更新回调
}
@Override
public void onTeamMemberJoined(List<V2NIMTeamMember> teamMembers) {
// 群组成员加入回调
}
@Override
public void onTeamMemberKicked(String operatorAccountId, List<V2NIMTeamMember> teamMembers) {
// 群组成员被踢回调
}
@Override
public void onTeamMemberLeft(List<V2NIMTeamMember> teamMembers) {
// 群组成员退出群组回调
}
@Override
public void onTeamMemberInfoUpdated(List<V2NIMTeamMember> teamMembers) {
// 群组成员信息更新回调
}
@Override
public void onReceiveTeamJoinActionInfo(V2NIMTeamJoinActionInfo joinActionInfo) {
// 入群操作回调
}
};
v2TeamService.addTeamListener(listener);
Objective-C[[[NIMSDK sharedSDK] v2TeamService] addTeamListener:self];
- (void)onSyncStarted{};
/**
* 同步完成
*/
- (void)onSyncFinished{};
/**
* 同步失败
*
* @param error 错误
*/
- (void)onSyncFailed:(V2NIMError *)error{};
/**
* 群组创建回调
*
* @param team 新创建的群组
*/
- (void)onTeamCreated:(V2NIMTeam *)team{};
/**
* 群组解散回调
*
* @param team 解散的群组
*
* @discussion 仅 teamId 和 teamType 字段有效
*/
- (void)onTeamDismissed:(V2NIMTeam *)team{};
/**
* 加入群组回调
*
* @param team 加入的群组
*/
- (void)onTeamJoined:(V2NIMTeam *)team{};
/**
* 离开群组回调
*
* @param team 离开的群组
* @param isKicked 是否被踢出群组
*
* @discussion 主动离开群组或被管理员踢出群组
*/
- (void)onTeamLeft:(V2NIMTeam *)team
isKicked:(BOOL)isKicked{};
/**
* 群组信息更新回调
*
* @param team 更新信息群组
*/
- (void)onTeamInfoUpdated:(V2NIMTeam *)team{};
/**
* 群组成员加入回调
*
* @param teamMembers 加入的群组成员列表
*/
- (void)onTeamMemberJoined:(NSArray<V2NIMTeamMember *> *)teamMembers{};
/**
* 群组成员被踢回调
*
* @param operatorAccountId 操作账号 ID
* @param teamMembers teamMembers 的群组成员列表
*/
- (void)onTeamMemberKicked:(NSString *)operatorAccountId
teamMembers:(NSArray<V2NIMTeamMember *> *)teamMembers{};
/**
* 群组成员退出回调
*
* @param teamMembers 退出的群组成员列表
*/
- (void)onTeamMemberLeft:(NSArray<V2NIMTeamMember *> *)teamMembers{};
/**
* 群组成员信息变更回调
*
* @param teamMembers 信息变更的群组成员列表
*/
- (void)onTeamMemberInfoUpdated:(NSArray<V2NIMTeamMember *> *)teamMembers{};
/**
* 入群操作回调
*
* @param joinActionInfo 入群操作信息
*/
- (void)onReceiveTeamJoinActionInfo:(V2NIMTeamJoinActionInfo *)joinActionInfo{};
C++V2NIMTeamListener listener;
listener.onSyncStarted = []() {
// team sync started
};
listener.onSyncFinished = []() {
// team sync finished
};
listener.onSyncFailed = [](V2NIMError error) {
// team sync failed, handle error
};
listener.onTeamCreated = [](V2NIMTeam team) {
// team created
};
listener.onTeamDismissed = [](nstd::vector<V2NIMTeam> teams) {
// team dismissed
};
listener.onTeamJoined = [](V2NIMTeam team) {
// team joined
};
listener.onTeamLeft = [](V2NIMTeam team, bool isKicked) {
// team left
};
listener.onTeamInfoUpdated = [](V2NIMTeam team) {
// team info updated
};
listener.onTeamMemberJoined = [](nstd::vector<V2NIMTeamMember> teamMembers) {
// team member joined
};
listener.onTeamMemberKicked = [](nstd::string operateAccountId, nstd::vector<V2NIMTeamMember> teamMembers) {
team member kicked
};
listener.onTeamMemberLeft = [](nstd::vector<V2NIMTeamMember> teamMembers) {
// team member left
};
listener.onTeamMemberInfoUpdated = [](nstd::vector<V2NIMTeamMember> teamMembers) {
// team member info updated
};
listener.onReceiveTeamJoinActionInfo = [](V2NIMTeamJoinActionInfo joinActionInfo) {
// receive team join action info
};
teamService.addTeamListener(listener);
返回参数
无。
removeTeamListener
接口描述
移除群组相关监听器。
该方法为同步。
参数说明
Javavoid removeTeamListener(V2NIMTeamListener listener);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
listener |
V2NIMTeamListener |
是 | 群组相关监听器。 |
Objective-C- (void)removeTeamListener:(id<V2NIMTeamListener>)listener;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
listener |
V2NIMTeamListener |
是 | 群组相关监听器。 |
C++virtual void removeTeamListener(V2NIMTeamListener listener) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
listener |
V2NIMTeamListener |
是 | 群组相关监听器。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
v2TeamService.removeTeamListener(listener);
Objective-C[[[NIMSDK sharedSDK] v2TeamService] removeTeamListener:self];
C++V2NIMTeamListener listener;
// ...
teamService.removeTeamListener(listener);
返回参数
无。
on("EventName")
接口描述
注册群组相关监听。
注册成功后,当事件发生时,SDK 会返回对应的回调。
-
建议在初始化后调用该方法。
-
全局只需注册一次。
-
该方法为同步。
参数说明
TypeScriptexport interface NIMEBaseServiceInterface<I extends NIMEBaseListener> {
/**
* 继承自 EventEmitter3 的监听事件方法。
*/
on<T extends keyof I>(eventName: T, fn: (...args: I[T]) => void): void;
/**
* 继承自 EventEmitter3 的监听事件方法。
*/
once<T extends keyof I>(eventName: T, fn: (...args: I[T]) => void): void;
}
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
eventName |
V2NIMTeamListener |
是 | 事件名称:onSyncStarted :群组信息同步开始回调,包括群组信息、群成员信息。onSyncFinished :群组信息同步结束回调。如果群组信息同步已开始,建议在同步结束后进行群组相关操作(例如查询群组列表),否则可能导致数据不完整。onSyncFailed :群组信息同步失败回调,返回 V2NIMError 错误码。收到该回调后进行群组相关操作可能导致数据不完整。onTeamCreated :群组成功创建回调,返回 V2NIMTeam 。当本地端或多端同步创建群组成功时会触发该回调。onTeamDismissed :群组解散回调,返回 V2NIMTeam 。当本地端或多端同步解散群组成功时会触发该回调。群组内所有成员均会收到该回调。onTeamJoined :加入群组回调,返回 V2NIMTeam 。当本地端或多端同步加入群组时会触发该回调。onTeamLeft :离开群组回调,返回 V2NIMTeam 。当本地端或多端主动离开群组或被踢出群组时会触发该回调。onTeamInfoUpdated :群组信息更新回调,返回 V2NIMTeam 。群组内所有成员均会收到该回调。onTeamMemberJoined :成员加入群组回调,返回 V2NIMTeamMember 。群组内所有成员均会收到该回调。onTeamMemberKicked :群成员被踢出群组回调,返回 V2NIMTeamMember 列表。群组内所有成员均会收到该回调。onTeamMemberLeft :群成员离开群组回调,返回 V2NIMTeamMember 列表。群组内所有成员均会收到该回调。onTeamMemberInfoUpdated :群成员信息变更回调,返回 V2NIMTeamMember 列表。群组内所有成员均会收到该回调。onReceiveTeamJoinActionInfo :收到入群操作信息回调,返回 V2NIMTeamJoinActionInfo 。 |
fn |
function | 是 | 监听事件的回调函数。当事件触发时,会调用该函数进行处理。 |
TypeScriptexport interface NIMEBaseServiceInterface<I extends NIMEBaseListener> {
/**
* 继承自 EventEmitter3 的监听事件方法。
*/
on<T extends keyof I>(eventName: T, fn: (...args: I[T]) => void): void;
/**
* 继承自 EventEmitter3 的监听事件方法。
*/
once<T extends keyof I>(eventName: T, fn: (...args: I[T]) => void): void;
}
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
eventName |
V2NIMTeamListener |
是 | 事件名称:syncStarted :群组信息同步开始回调,包括群组信息、群成员信息。syncFinished :群组信息同步结束回调。如果群组信息同步已开始,建议在同步结束后进行群组相关操作(例如查询群组列表),否则可能导致数据不完整。syncFailed :群组信息同步失败回调,返回 V2NIMError 错误码。收到该回调后进行群组相关操作可能导致数据不完整。teamCreated :群组成功创建回调,返回 V2NIMTeam 。当本地端或多端同步创建群组成功时会触发该回调。teamDismissed :群组解散回调,返回 V2NIMTeam 。当本地端或多端同步解散群组成功时会触发该回调。群组内所有成员均会收到该回调。teamJoined :加入群组回调,返回 V2NIMTeam 。当本地端或多端同步加入群组时会触发该回调。teamLeft :离开群组回调,返回 V2NIMTeam 。当本地端或多端主动离开群组或被踢出群组时会触发该回调。teamInfoUpdated :群组信息更新回调,返回 V2NIMTeam 。群组内所有成员均会收到该回调。teamMemberJoined :成员加入群组回调,返回 V2NIMTeamMember 。群组内所有成员均会收到该回调。teamMemberKicked :群成员被踢出群组回调,返回 V2NIMTeamMember 列表。群组内所有成员均会收到该回调。teamMemberLeft :群成员离开群组回调,返回 V2NIMTeamMember 列表。群组内所有成员均会收到该回调。teamMemberInfoUpdated :群成员信息变更回调,返回 V2NIMTeamMember 列表。群组内所有成员均会收到该回调。receiveTeamJoinActionInfo :收到入群操作信息回调,返回 V2NIMTeamJoinActionInfo 。 |
fn |
function | 是 | 监听事件的回调函数。当事件触发时,会调用该函数进行处理。 |
TypeScriptexport interface NIMEBaseServiceInterface<I extends NIMEBaseListener> {
/**
* 继承自 eventEmitter3 的监听事件方法
*/
on<T extends keyof I>(eventName: T, fn: (...args: I[T]) => void): void
/**
* 继承自 eventEmitter3 的监听事件方法
*/
once<T extends keyof I>(eventName: T, fn: (...args: I[T]) => void): void
}
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
eventName |
V2NIMTeamListener |
是 | 事件名称:onSyncStarted :群组信息同步开始回调,包括群组信息、群成员信息。onSyncFinished :群组信息同步结束回调。如果群组信息同步已开始,建议在同步结束后进行群组相关操作(例如查询群组列表),否则可能导致数据不完整。onSyncFailed :群组信息同步失败回调,返回 V2NIMError 错误码。收到该回调后进行群组相关操作可能导致数据不完整。onTeamCreated :群组成功创建回调,返回 V2NIMTeam 。当本地端或多端同步创建群组成功时会触发该回调。onTeamDismissed :群组解散回调,返回 V2NIMTeam 。当本地端或多端同步解散群组成功时会触发该回调。群组内所有成员均会收到该回调。onTeamJoined :加入群组回调,返回 V2NIMTeam 。当本地端或多端同步加入群组时会触发该回调。onTeamLeft :离开群组回调,返回 V2NIMTeam 。当本地端或多端主动离开群组或被踢出群组时会触发该回调。onTeamInfoUpdated :群组信息更新回调,返回 V2NIMTeam 。群组内所有成员均会收到该回调。onTeamMemberJoined :成员加入群组回调,返回 V2NIMTeamMember 。群组内所有成员均会收到该回调。onTeamMemberKicked :群成员被踢出群组回调,返回 V2NIMTeamMember 列表。群组内所有成员均会收到该回调。onTeamMemberLeft :群成员离开群组回调,返回 V2NIMTeamMember 列表。群组内所有成员均会收到该回调。onTeamMemberInfoUpdated :群成员信息变更回调,返回 V2NIMTeamMember 列表。群组内所有成员均会收到该回调。onReceiveTeamJoinActionInfo :收到入群操作信息回调,返回 V2NIMTeamJoinActionInfo 。 |
fn |
function | 是 | 监听事件的回调函数。当事件触发时,会调用该函数进行处理。 |
示例代码
TypeScriptnim.V2NIMTeamService.on('onSyncStarted', () => { console.log("recv onSyncStarted") })
nim.V2NIMTeamService.on('onSyncFinished', () => { console.log("recv onSyncFinished") })
nim.V2NIMTeamService.on('onSyncFailed', (error) => { console.log("recv onSyncFailed", error) })
nim.V2NIMTeamService.on('onTeamCreated', (team) => { console.log("recv onTeamCreated", team) })
nim.V2NIMTeamService.on('onTeamDismissed', (team) => { console.log("recv onTeamDismissed", team) })
nim.V2NIMTeamService.on('onTeamJoined', (team) => { console.log("recv onTeamJoined", team) })
nim.V2NIMTeamService.on('onTeamLeft', (team, isKicked) => { console.log("recv onTeamLeft", team, isKicked) })
nim.V2NIMTeamService.on('onTeamInfoUpdated', (team) => { console.log("recv onTeamInfoUpdated", team) })
nim.V2NIMTeamService.on('onTeamMemberJoined', (teamMembers) => { console.log("recv onTeamMemberJoined", teamMembers) })
nim.V2NIMTeamService.on('onTeamMemberKicked', (operateAccountId, teamMembers) => { console.log("recv onTeamMemberKicked", operateAccountId, teamMembers) })
nim.V2NIMTeamService.on('onTeamMemberLeft', (teamMembers) => { console.log("recv onTeamMemberLeft", teamMembers) })
nim.V2NIMTeamService.on('onTeamMemberInfoUpdated', (teamMembers) => { console.log("recv onTeamMemberInfoUpdated", teamMembers) })
nim.V2NIMTeamService.on('onReceiveTeamJoinActionInfo', (joinActionInfo) => { console.log("recv onReceiveTeamJoinActionInfo", joinActionInfo) })
TypeScriptv2.teamService.on('syncStarted', () => { console.log("recv onSyncStarted") })
v2.teamService.on('syncFinished', () => { console.log("recv onSyncFinished") })
v2.teamService.on('syncFailed', (error) => { console.log("recv onSyncFailed", error) })
v2.teamService.on('teamCreated', (team) => { console.log("recv onTeamCreated", team) })
v2.teamService.on('teamDismissed', (team) => { console.log("recv onTeamDismissed", team) })
v2.teamService.on('teamJoined', (team) => { console.log("recv onTeamJoined", team) })
v2.teamService.on('teamLeft', (team, isKicked) => { console.log("recv onTeamLeft", team, isKicked) })
v2.teamService.on('teamInfoUpdated', (team) => { console.log("recv onTeamInfoUpdated", team) })
v2.teamService.on('teamMemberJoined', (teamMembers) => { console.log("recv onTeamMemberJoined", teamMembers) })
v2.teamService.on('teamMemberKicked', (operateAccountId, teamMembers) => { console.log("recv onTeamMemberKicked", operateAccountId, teamMembers) })
v2.teamService.on('teamMemberLeft', (teamMembers) => { console.log("recv onTeamMemberLeft", teamMembers) })
v2.teamService.on('teamMemberInfoUpdated', (teamMembers) => { console.log("recv onTeamMemberInfoUpdated", teamMembers) })
v2.teamService.on('receiveTeamJoinActionInfo', (joinActionInfo) => { console.log("recv onReceiveTeamJoinActionInfo", joinActionInfo) })
TypeScriptnim.teamService.on('onSyncStarted', () => { console.log("recv onSyncStarted") })
nim.teamService.on('onSyncFinished', () => { console.log("recv onSyncFinished") })
nim.teamService.on('onSyncFailed', (error) => { console.log("recv onSyncFailed", error) })
nim.teamService.on('onTeamCreated', (team) => { console.log("recv onTeamCreated", team) })
nim.teamService.on('onTeamDismissed', (team) => { console.log("recv onTeamDismissed", team) })
nim.teamService.on('onTeamJoined', (team) => { console.log("recv onTeamJoined", team) })
nim.teamService.on('onTeamLeft', (team, isKicked) => { console.log("recv onTeamLeft", team, isKicked) })
nim.teamService.on('onTeamInfoUpdated', (team) => { console.log("recv onTeamInfoUpdated", team) })
nim.teamService.on('onTeamMemberJoined', (teamMembers) => { console.log("recv onTeamMemberJoined", teamMembers) })
nim.teamService.on('onTeamMemberKicked', (operateAccountId, teamMembers) => { console.log("recv onTeamMemberKicked", operateAccountId, teamMembers) })
nim.teamService.on('onTeamMemberLeft', (teamMembers) => { console.log("recv onTeamMemberLeft", teamMembers) })
nim.teamService.on('onTeamMemberInfoUpdated', (teamMembers) => { console.log("recv onTeamMemberInfoUpdated", teamMembers) })
nim.teamService.on('onReceiveTeamJoinActionInfo', (joinActionInfo) => { console.log("recv onReceiveTeamJoinActionInfo", joinActionInfo) })
返回参数
无。
off("EventName")
接口描述
取消注册群组相关监听。
该方法为同步。
参数说明
TypeScriptexport interface NIMEBaseServiceInterface<I extends NIMEBaseListener> {
/**
* 继承自 EventEmitter3 的取消监听方法。
*/
off<T extends keyof I>(eventName: T, fn: (...args: I[T]) => void): void;
/**
* 继承自 EventEmitter3 的移除事件方法。
*/
removeAllListeners<T extends keyof I>(eventName?: T): void;
}
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
eventName |
V2NIMTeamListener |
是 | 事件名称:onSyncStarted :群组信息同步开始回调,包括群组信息、群成员信息。onSyncFinished :群组信息同步结束回调。如果群组信息同步已开始,建议在同步结束后进行群组相关操作(例如查询群组列表),否则可能导致数据不完整。onSyncFailed :群组信息同步失败回调,返回 V2NIMError 错误码。收到该回调后进行群组相关操作可能导致数据不完整。onTeamCreated :群组成功创建回调,返回 V2NIMTeam 。当本地端或多端同步创建群组成功时会触发该回调。onTeamDismissed :群组解散回调,返回 V2NIMTeam 。当本地端或多端同步解散群组成功时会触发该回调。群组内所有成员均会收到该回调。onTeamJoined :加入群组回调,返回 V2NIMTeam 。当本地端或多端同步加入群组时会触发该回调。onTeamLeft :离开群组回调,返回 V2NIMTeam 。当本地端或多端主动离开群组或被踢出群组时会触发该回调。onTeamInfoUpdated :群组信息更新回调,返回 V2NIMTeam 。群组内所有成员均会收到该回调。onTeamMemberJoined :成员加入群组回调,返回 V2NIMTeamMember 。群组内所有成员均会收到该回调。onTeamMemberKicked :群成员被踢出群组回调,返回 V2NIMTeamMember 列表。群组内所有成员均会收到该回调。onTeamMemberLeft :群成员离开群组回调,返回 V2NIMTeamMember 列表。群组内所有成员均会收到该回调。onTeamMemberInfoUpdated :群成员信息变更回调,返回 V2NIMTeamMember 列表。群组内所有成员均会收到该回调。onReceiveTeamJoinActionInfo :收到入群操作信息回调,返回 V2NIMTeamJoinActionInfo 。 |
fn |
function | 否 | 监听事件的回调函数。当事件触发时,会调用该函数进行处理。 |
TypeScriptexport interface NIMEBaseServiceInterface<I extends NIMEBaseListener> {
/**
* 继承自 EventEmitter3 的取消监听方法。
*/
off<T extends keyof I>(eventName: T, fn: (...args: I[T]) => void): void;
/**
* 继承自 EventEmitter3 的移除事件方法。
*/
removeAllListeners<T extends keyof I>(eventName?: T): void;
}
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
eventName |
V2NIMTeamListener |
是 | 事件名称:syncStarted :群组信息同步开始回调,包括群组信息、群成员信息。syncFinished :群组信息同步结束回调。如果群组信息同步已开始,建议在同步结束后进行群组相关操作(例如查询群组列表),否则可能导致数据不完整。syncFailed :群组信息同步失败回调,返回 V2NIMError 错误码。收到该回调后进行群组相关操作可能导致数据不完整。teamCreated :群组成功创建回调,返回 V2NIMTeam 。当本地端或多端同步创建群组成功时会触发该回调。teamDismissed :群组解散回调,返回 V2NIMTeam 。当本地端或多端同步解散群组成功时会触发该回调。群组内所有成员均会收到该回调。teamJoined :加入群组回调,返回 V2NIMTeam 。当本地端或多端同步加入群组时会触发该回调。teamLeft :离开群组回调,返回 V2NIMTeam 。当本地端或多端主动离开群组或被踢出群组时会触发该回调。teamInfoUpdated :群组信息更新回调,返回 V2NIMTeam 。群组内所有成员均会收到该回调。teamMemberJoined :成员加入群组回调,返回 V2NIMTeamMember 。群组内所有成员均会收到该回调。teamMemberKicked :群成员被踢出群组回调,返回 V2NIMTeamMember 列表。群组内所有成员均会收到该回调。teamMemberLeft :群成员离开群组回调,返回 V2NIMTeamMember 列表。群组内所有成员均会收到该回调。teamMemberInfoUpdated :群成员信息变更回调,返回 V2NIMTeamMember 列表。群组内所有成员均会收到该回调。receiveTeamJoinActionInfo :收到入群操作信息回调,返回 V2NIMTeamJoinActionInfo 。 |
fn |
function | 否 | 监听事件的回调函数。当事件触发时,会调用该函数进行处理。 |
TypeScriptexport interface NIMEBaseServiceInterface<I extends NIMEBaseListener> {
/**
* 继承自 eventEmitter3 的取消监听方法
*/
off<T extends keyof I>(eventName: T, fn: (...args: I[T]) => void): void
/**
* 继承自 eventEmitter3 的移除事件方法
*/
removeAllListeners<T extends keyof I>(eventName?: T): void
}
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
eventName |
V2NIMTeamListener |
是 | 事件名称:onSyncStarted :群组信息同步开始回调,包括群组信息、群成员信息。onSyncFinished :群组信息同步结束回调。如果群组信息同步已开始,建议在同步结束后进行群组相关操作(例如查询群组列表),否则可能导致数据不完整。onSyncFailed :群组信息同步失败回调,返回 V2NIMError 错误码。收到该回调后进行群组相关操作可能导致数据不完整。onTeamCreated :群组成功创建回调,返回 V2NIMTeam 。当本地端或多端同步创建群组成功时会触发该回调。onTeamDismissed :群组解散回调,返回 V2NIMTeam 。当本地端或多端同步解散群组成功时会触发该回调。群组内所有成员均会收到该回调。onTeamJoined :加入群组回调,返回 V2NIMTeam 。当本地端或多端同步加入群组时会触发该回调。onTeamLeft :离开群组回调,返回 V2NIMTeam 。当本地端或多端主动离开群组或被踢出群组时会触发该回调。onTeamInfoUpdated :群组信息更新回调,返回 V2NIMTeam 。群组内所有成员均会收到该回调。onTeamMemberJoined :成员加入群组回调,返回 V2NIMTeamMember 。群组内所有成员均会收到该回调。onTeamMemberKicked :群成员被踢出群组回调,返回 V2NIMTeamMember 列表。群组内所有成员均会收到该回调。onTeamMemberLeft :群成员离开群组回调,返回 V2NIMTeamMember 列表。群组内所有成员均会收到该回调。onTeamMemberInfoUpdated :群成员信息变更回调,返回 V2NIMTeamMember 列表。群组内所有成员均会收到该回调。onReceiveTeamJoinActionInfo :收到入群操作信息回调,返回 V2NIMTeamJoinActionInfo 。 |
fn |
function | 否 | 监听事件的回调函数。当事件触发时,会调用该函数进行处理。 |
示例代码
TypeScript// remove one listeners
nim.V2NIMTeamService.off("onSyncStarted")
// remove all listeners
nim.V2NIMTeamService.removeAllListeners()
TypeScript// remove one listeners
v2.teamService.off("syncStarted")
// remove all listeners
v2.teamService.removeAllListeners()
TypeScript// remove one listeners
nim.teamService.off('onSyncStarted', theListner)
nim.teamService.off('onSyncFinished', theListner)
nim.teamService.off('onSyncFailed', theListner)
nim.teamService.off('onTeamCreated', theListner)
nim.teamService.off('onTeamDismissed', theListner)
nim.teamService.off('onTeamJoined', theListner)
nim.teamService.off('onTeamLeft', theListner)
nim.teamService.off('onTeamInfoUpdated', theListner)
nim.teamService.off('onTeamMemberJoined', theListner)
nim.teamService.off('onTeamMemberKicked', theListner)
nim.teamService.off('onTeamMemberLeft', theListner)
nim.teamService.off('onTeamMemberInfoUpdated', theListner})
nim.teamService.off('onReceiveTeamJoinActionInfo', theListner)
// remove all listeners
nim.teamService.removeAllListeners()
返回参数
无。
createTeam
接口描述
创建一个群组。支持创建高级群和超大群,二者区别请参考 群组概述。
本地端或多端同步创建成功后,SDK 会返回创建成功回调 onTeamCreated
,并同步缓存和数据库。
参数说明
Javavoid createTeam(V2NIMCreateTeamParams createTeamParams, List<String> inviteeAccountIds, String postscript, V2NIMAntispamConfig antispamConfig, V2NIMSuccessCallback<V2NIMCreateTeamResult> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
createTeamParams |
V2NIMCreateTeamParams |
是 | 群组创建配置参数。 |
inviteeAccountIds |
List |
否 | 被邀请加入群组的成员列表,单次调用不超过 50 人。 |
postscript |
String | 否 | 邀请入群附言。 |
antispamConfig |
V2NIMAntispamConfig |
否 | 易盾反垃圾相关配置。 |
success |
V2NIMSuccessCallback |
是 | 群组创建成功回调,返回 V2NIMCreateTeamResult 。 |
failure |
V2NIMFailureCallback |
是 | 群组创建失败回调,返回 错误码。 |
Objective-C- (void)createTeam:(V2NIMCreateTeamParams *)createTeamParams
inviteeAccountIds:(nullable NSArray<NSString *> *)inviteeAccountIds
postscript:(nullable NSString *)postscript
antispamConfig:(nullable V2NIMAntispamConfig *)antispamConfig
success:(nullable V2NIMCreateTeamResultCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
createTeamParams |
V2NIMCreateTeamParams |
是 | 群组创建配置参数。 |
inviteeAccountIds |
NSArray<NSString *> * | 否 | 被邀请加入群组的成员列表,单次调用不超过 50 人。 |
postscript |
NSString * | 否 | 邀请入群附言。 |
antispamConfig |
V2NIMAntispamConfig |
否 | 易盾反垃圾相关配置。 |
success |
V2NIMCreateTeamResultCallback |
是 | 群组创建成功回调,可自定义设置。 |
failure |
V2NIMFailureCallback |
是 | 群组创建失败回调,返回 错误码。 |
C++virtual void createTeam(V2NIMCreateTeamParams createTeamParams,
std::vector<std::string> inviteeAccountIds,
std::string postscript,
V2NIMAntispamConfig antispamConfig,
V2NIMSuccessCallback<V2NIMCreateTeamResult> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
createTeamParams |
V2NIMCreateTeamParams |
是 | 群组创建配置参数。 |
inviteeAccountIds |
vector<std::string> | 否 | 被邀请加入群组的成员列表,单次调用不超过 50 人。 |
postscript |
string | 否 | 邀请入群附言。 |
antispamConfig |
V2NIMAntispamConfig |
否 | 易盾反垃圾相关配置。 |
success |
V2NIMSuccessCallback |
是 | 群组创建成功回调,返回 V2NIMCreateTeamResult 。 |
failure |
V2NIMFailureCallback |
是 | 群组创建失败回调,返回 错误码。 |
TypeScriptcreateTeam(
createTeamParams: V2NIMCreateTeamParams,
inviteeAccountIds?: string[],
postscript?: string,
antispamConfig?: V2NIMAntispamConfig
): Promise<V2NIMCreateTeamResult>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
createTeamParams |
V2NIMCreateTeamParams |
是 | 群组创建配置参数。 |
inviteeAccountIds |
string[] | 否 | 被邀请加入群组的成员列表,单次调用不超过 50 人。 |
postscript |
string | 否 | 邀请入群附言。 |
antispamConfig |
V2NIMAntispamConfig |
否 | 易盾反垃圾相关配置。 |
TypeScriptcreateTeam(createTeamParams, inviteeAccountIds, postscript, antispamConfig): Promise<V2NIMCreateTeamResult>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
createTeamParams |
V2NIMCreateTeamParams |
是 | 群组创建配置参数。 |
inviteeAccountIds |
string[] | 否 | 被邀请加入群组的成员列表,单次调用不超过 50 人。 |
postscript |
string | 否 | 邀请入群附言。 |
antispamConfig |
V2NIMAntispamConfig |
否 | 易盾反垃圾相关配置。 |
TypeScriptcreateTeam(
createTeamParams: V2NIMCreateTeamParams,
inviteeAccountIds?: string[],
postscript?: string,
antispamConfig?: V2NIMAntispamConfig
): Promise<V2NIMCreateTeamResult>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
createTeamParams |
V2NIMCreateTeamParams |
是 | 群组创建配置参数。 |
inviteeAccountIds |
string[] | 否 | 被邀请加入群组的成员列表,单次调用不超过 50 人。 |
postscript |
string | 否 | 邀请入群附言。 |
antispamConfig |
V2NIMAntispamConfig |
否 | 易盾反垃圾相关配置。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
// 创建群组参数
V2NIMCreateTeamParams createTeamParams = new V2NIMCreateTeamParams();
createTeamParams.setName("test");
createTeamParams.setTeamType(V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL);
createTeamParams.setMemberLimit(100);
createTeamParams.setIntro("test");
createTeamParams.setAnnouncement("test");
createTeamParams.setAvatar("http://test.png");
createTeamParams.setServerExtension("test");
createTeamParams.setAgreeMode(V2NIMTeamAgreeMode.V2NIM_TEAM_AGREE_MODE_AUTH);
createTeamParams.setJoinMode(V2NIMTeamJoinMode.V2NIM_TEAM_JOIN_MODE_INVITE);
createTeamParams.setInviteMode(V2NIMTeamInviteMode.V2NIM_TEAM_INVITE_MODE_MANAGER);
createTeamParams.setUpdateInfoMode(V2NIMTeamUpdateInfoMode.V2NIM_TEAM_UPDATE_INFO_MODE_MANAGER);
createTeamParams.setUpdateExtensionMode(V2NIMTeamUpdateExtensionMode.V2NIM_TEAM_UPDATE_EXTENSION_MODE_MANAGER);
// 创建群组时,同时被邀请加入群的成员列表
List<String> inviteeAccountIds = new ArrayList<>();
inviteeAccountIds.add("test1");
inviteeAccountIds.add("test2");
String postscript = "test";
// 易盾反垃圾配置,如果不审核,该配置不需要配置。如果开启了安全通,默认采用安全通,该配置不需要配置。如果需要审核,且直接对接易盾,则配置该配置
V2NIMAntispamConfig antispamConfig = null;
v2TeamService.createTeam(createTeamParams, inviteeAccountIds, postscript, antispamConfig, result -> {
// 创建群组成功
}, error -> {
// 创建群组失败
});
Objective-CV2NIMCreateTeamParams *teamParams = [V2NIMCreateTeamParams new];
teamParams.name = @"test";
teamParams.teamType = V2NIM_TEAM_TYPE_NORMAL;
teamParams.memberLimit = 100;
teamParams.intro = @"test";
teamParams.announcement = @"test";
teamParams.avatar = @"http://test.png";
teamParams.agreeMode = V2NIM_TEAM_AGREE_MODE_AUTH;
teamParams.joinMode = V2NIM_TEAM_JOIN_MODE_FREE;
teamParams.inviteMode = V2NIM_TEAM_INVITE_MODE_MANAGER;
teamParams.updateInfoMode = V2NIM_TEAM_UPDATE_INFO_MODE_MANAGER;
teamParams.updateExtensionMode = V2NIM_TEAM_UPDATE_EXTENSION_MODE_MANAGER;
V2NIMAntispamConfig *config = [V2NIMAntispamConfig new];
[[[NIMSDK sharedSDK] v2TeamService] createTeam:teamParams inviteeAccountIds:@[@"test1",@"test2"] postscript:@"test" antispamConfig:config success:^(V2NIMCreateTeamResult * _Nonnull result) {
// 群组创建成功
} failure:^(V2NIMError * _Nonnull error) {
// 群组创建失败
}];
C++V2NIMCreateTeamParams createTeamParams;
createTeamParams.name = "teamName";
nstd::vector<nstd::string> inviteeAccountIds;
inviteeAccountIds.push_back("account1");
V2NIMAntispamConfig antispamConfig;
teamService.createTeam(
createTeamParams,
inviteeAccountIds,
"postscript",
antispamConfig,
[](V2NIMCreateTeamResult result) {
// do something
},
[](V2NIMError error) {
// get message list failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.createTeam(
{
"name": "群名",
"teamType": 1,
"memberLimit": 200,
}
)
TypeScriptconst result = await v2.teamService.createTeam({
name: 'team1',
teamType: 0,
}, inviteeAccountIds, postscript, antispamConfig)
TypeScripttry {
const params: V2NIMCreateTeamParams = {
name: this.name,
teamType: this.teamType,
memberLimit: this.memberLimit,
intro: this.intro,
announcement: this.announcement,
avatar: this.avatar,
serverExtension: this.serverExtension,
joinMode: this.joinMode,
agreeMode: this.agreeMode,
inviteMode: this.inviteMode,
updateInfoMode: this.updateInfoMode,
updateExtensionMode: this.updateExtensionMode,
chatBannedMode: this.chatBannedMode
}
const result:V2NIMCreateTeamResult = await nim.teamService.createTeam(params, [], '')
// success
} catch (error) {
// fail
}
返回参数
无返回值。
Promise<V2NIMCreateTeamResult
> 群组创建结果
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调,包含V2NIMCreateTeamResult
。创建成功,返回onTeamCreated
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
- 请求成功,返回
V2NIMCreateTeamResultCallback
回调,可自定义设置。创建成功,返回onTeamCreated
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
创建成功,返回 onTeamCreated
回调。
创建成功,返回 teamCreated
回调。
leaveTeam
接口描述
退出指定群组。
本地端或多端同步退出群组成功后:
- 本端 SDK 会触发退出群组回调
onTeamLeft
。 - 群组内所有成员会收到通知消息,通知消息类型为
V2NIMMessageNotificationType.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_LAVE(2)
。以及onTeamMemberLeft
回调。
参数说明
Javavoid leaveTeam(String teamId, V2NIMTeamType teamType,V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
success |
V2NIMSuccessCallback |
是 | 离开群组成功回调。 |
failure |
V2NIMFailureCallback |
是 | 离开群组失败回调,返回 错误码。 |
Objective-C- (void)leaveTeam:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString * | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
success |
V2NIMSuccessCallback |
是 | 离开群组成功回调。 |
failure |
V2NIMFailureCallback |
是 | 离开群组失败回调,返回 错误码。 |
C++virtual void leaveTeam(nstd::string teamId, V2NIMTeamType teamType, V2NIMSuccessCallback<void> success, V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
nstd::string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
success |
V2NIMSuccessCallback |
是 | 离开群组成功回调。 |
failure |
V2NIMFailureCallback |
是 | 离开群组失败回调,返回 错误码。 |
TypeScriptleaveTeam(teamId: string, teamType: V2NIMTeamType): Promise<V2NIMLeaveTeamResult>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
TypeScriptleaveTeam(teamId, teamType): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
TypeScriptleaveTeam(teamId: string, teamType: V2NIMTeamType): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
String teamId = "123456";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
v2TeamService.leaveTeam(teamId,teamType, result -> {
// 离开群组成功
}, error -> {
// 离开群组失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] leaveTeam:@"teamId" teamType:V2NIM_TEAM_TYPE_NORMAL success:^{
// 离开群组成功
} failure:^(V2NIMError * _Nonnull error) {
// 离开群组失败
}];
C++teamService.leaveTeam(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
[]() {
// leave team success
},
[](V2NIMError error) {
// leave team failed, handle error
}
);
TypeScriptawait nim.V2NIMTeamService.leaveTeam("123456", 1)
TypeScriptawait v2.teamService.leaveTeam(teamId, teamType)
TypeScriptconst teamId = "123456"
const teamType: V2NIMTeamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL
try {
await nim.teamService.leaveTeam(teamId, teamType)
// success
} catch (error) {
// fail
}
返回参数
无返回值。
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。退出群组成功,返回onTeamLeft
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
退出群组成功,返回 onTeamLeft
回调。
退出群组成功,返回 teamLeft
回调。
updateTeamInfo
接口描述
更新指定群组信息。
本地端或多端同步更新成功后,群组内所有成员会收到群组信息变更回调 onTeamInfoUpdated
,以及群组信息更新的通知消息,通知消息类型为 V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_UPDATE_TINFO(3)
。
更新前请确保该群组已存在。
参数说明
Javavoid updateTeamInfo(String teamId, V2NIMTeamType teamType, V2NIMUpdateTeamInfoParams updateTeamInfoParams, V2NIMAntispamConfig antispamConfig,V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
updateTeamInfoParams |
V2NIMUpdateTeamInfoParams |
是 | 群组信息更新配置参数。 |
antispamConfig |
V2NIMAntispamConfig |
否 | 易盾反垃圾相关配置。 |
success |
V2NIMSuccessCallback |
是 | 更新群组信息成功回调。 |
failure |
V2NIMFailureCallback |
是 | 更新群组信息失败回调,返回 错误码。 |
Objective-C- (void)updateTeamInfo:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
updateTeamInfoParams:(V2NIMUpdateTeamInfoParams *)updateTeamInfoParams
antispamConfig:(nullable V2NIMAntispamConfig *)antispamConfig
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString * | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
updateTeamInfoParams |
V2NIMUpdateTeamInfoParams |
是 | 群组信息更新配置参数。 |
antispamConfig |
V2NIMAntispamConfig |
否 | 易盾反垃圾相关配置。 |
success |
V2NIMSuccessCallback |
是 | 更新群组信息成功回调。 |
failure |
V2NIMFailureCallback |
是 | 更新群组信息失败回调,返回 错误码。 |
C++virtual void updateTeamInfo(std::string teamId,
V2NIMTeamType teamType,
V2NIMUpdateTeamInfoParams updateTeamInfoParams,
V2NIMAntispamConfig antispamConfig,
V2NIMSuccessCallback<void> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
std::string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
updateTeamInfoParams |
V2NIMUpdateTeamInfoParams |
是 | 群组信息更新配置参数。 |
antispamConfig |
V2NIMAntispamConfig |
否 | 易盾反垃圾相关配置。 |
success |
V2NIMSuccessCallback |
是 | 更新群组信息成功回调。 |
failure |
V2NIMFailureCallback |
是 | 更新群组信息失败回调,返回 错误码。 |
TypeScriptupdateTeamInfo(teamId: string, teamType: V2NIMTeamType, updateTeamInfoParams: V2NIMUpdateTeamInfoParams, antispamConfig?: V2NIMAntispamConfig): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
updateTeamInfoParams |
V2NIMUpdateTeamInfoParams |
是 | 群组信息更新配置参数。 |
antispamConfig |
V2NIMAntispamConfig |
否 | 易盾反垃圾相关配置。 |
TypeScriptupdateTeamInfo(teamId, teamType, updateTeamInfoParams, antispamConfig): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
updateTeamInfoParams |
V2NIMUpdateTeamInfoParams |
是 | 群组信息更新配置参数。 |
antispamConfig |
V2NIMAntispamConfig |
否 | 易盾反垃圾相关配置。 |
TypeScriptupdateTeamInfo(teamId: string, teamType: V2NIMTeamType, updateTeamInfoParams: V2NIMUpdateTeamInfoParams, antispamConfig?: V2NIMAntispamConfig): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
updateTeamInfoParams |
V2NIMUpdateTeamInfoParams |
是 | 群组信息更新配置参数。 |
antispamConfig |
V2NIMAntispamConfig |
否 | 易盾反垃圾相关配置。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
String teamId = "123456";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
V2NIMUpdateTeamInfoParams updateTeamInfoParams = new V2NIMUpdateTeamInfoParams();
updateTeamInfoParams.setName("test_update");
updateTeamInfoParams.setMemberLimit(100);
updateTeamInfoParams.setIntro("test");
updateTeamInfoParams.setAnnouncement("test");
updateTeamInfoParams.setAvatar("http://test.png");
updateTeamInfoParams.setServerExtension("test");
updateTeamInfoParams.setAgreeMode(V2NIMTeamAgreeMode.V2NIM_TEAM_AGREE_MODE_AUTH);
updateTeamInfoParams.setJoinMode(V2NIMTeamJoinMode.V2NIM_TEAM_JOIN_MODE_INVITE);
updateTeamInfoParams.setInviteMode(V2NIMTeamInviteMode.V2NIM_TEAM_INVITE_MODE_MANAGER);
updateTeamInfoParams.setUpdateInfoMode(V2NIMTeamUpdateInfoMode.V2NIM_TEAM_UPDATE_INFO_MODE_MANAGER);
updateTeamInfoParams.setUpdateExtensionMode(V2NIMTeamUpdateExtensionMode.V2NIM_TEAM_UPDATE_EXTENSION_MODE_MANAGER);
// 易盾反垃圾配置,如果不审核,该配置不需要配置。如果开启了安全通,默认采用安全通,该配置不需要配置。如果需要审核,且直接对接易盾,则配置该配置
V2NIMAntispamConfig antispamConfig = null;
v2TeamService.updateTeamInfo(teamId,teamType, updateTeamInfoParams, antispamConfig, result -> {
// 修改群组信息成功
}, error -> {
// 修改群组信息失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] updateTeamInfo:@"teamId" teamType:V2NIM_TEAM_TYPE_NORMAL updateTeamInfoParams:infoParams antispamConfig:config success:^{
// 修改群组信息成功
} failure:^(V2NIMError * _Nonnull error) {
// 修改群组信息失败
}];
C++V2NIMUpdateTeamInfoParams updateTeamInfoParams;
updateTeamInfoParams.name = "new team name";
V2NIMAntispamConfig antispamConfig;
teamService.updateTeamInfo(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
updateTeamInfoParams,
antispamConfig,
[]() {
// update team info success
},
[](V2NIMError error) {
// update team info failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.updateTeamInfo(
"123456",
1,
{
"name": "群名 1",
"memberLimit": 200,
"joinMode": 0,
"agreeMode": 0,
"inviteMode": 0,
"updateInfoMode": 0,
"updateExtensionMode": 0,
"chatBannedMode": 0
}
)
TypeScriptawait v2.teamService.updateTeamInfo(teamId, teamType, {
"name": "群名 1",
"memberLimit": 200,
"joinMode": 0,
"agreeMode": 0,
"inviteMode": 0,
"updateInfoMode": 0,
"updateExtensionMode": 0,
"chatBannedMode": 0
}, antispamConfig)
TypeScripttry {
console.info(`----update team---- \n`)
const params: V2NIMUpdateTeamInfoParams = {
name: this.name,
memberLimit: this.memberLimit,
intro: this.intro,
announcement: this.announcement,
avatar: this.avatar,
serverExtension: this.serverExtension,
joinMode: this.joinMode,
agreeMode: this.agreeMode,
inviteMode: this.inviteMode,
updateInfoMode: this.updateInfoMode,
updateExtensionMode: this.updateExtensionMode,
}
await nim.teamService.updateTeamInfo(this.teamId, this.teamType, params )
// success
} catch (error) {
// fail
}
返回参数
无返回值。
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。更新成功,返回onTeamInfoUpdated
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
更新成功,返回 onTeamInfoUpdated
回调。
更新成功,返回 teamInfoUpdated
回调。
getTeamInfo
接口描述
获取指定的单个群组信息。
- 获取前请确保指定的群组存在。
- 群组数据同步(
V2NIMTeamListener.onSyncFinished
)完成前,可能获取不到完整数据。
参数说明
Javavoid getTeamInfo(String teamId, V2NIMTeamType teamType,V2NIMSuccessCallback<V2NIMTeam> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
success |
V2NIMSuccessCallback |
是 | 获取成功回调,返回 V2NIMTeam 。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
Objective-C- (void)getTeamInfo:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
success:(nullable V2NIMTeamInfoCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString * | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
success |
V2NIMTeamInfoCallback |
是 | 获取成功回调,可自定义设置。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
C++virtual void getTeamInfo(nstd::string teamId, V2NIMTeamType teamType, V2NIMSuccessCallback<V2NIMTeam> success, V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
nstd::string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
success |
V2NIMSuccessCallback |
是 | 获取成功回调,返回 V2NIMTeam 。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
TypeScriptgetTeamInfo(teamId: string, teamType: V2NIMTeamType): Promise<V2NIMTeam>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
TypeScriptgetTeamInfo(teamId, teamType): Promise<V2NIMTeam>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
TypeScriptgetTeamInfo(teamId: string, teamType: V2NIMTeamType): Promise<V2NIMTeam>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
String teamId = "123456";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
v2TeamService.getTeamInfo(teamId,teamType, result -> {
// 获取群组信息成功
}, error -> {
// 获取群组信息失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] getTeamInfo:@"teamId" teamType:V2NIM_TEAM_TYPE_NORMAL success:^(V2NIMTeam * _Nonnull team) {
// 获取群组信息成功
} failure:^(V2NIMError * _Nonnull error) {
// 获取群组信息失败
}];
C++teamService.getTeamInfo(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
[](V2NIMTeam team) {
// get team info success
},
[](V2NIMError error) {
// get team info failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.getTeamInfo("123456", 1)
TypeScriptconst team = await v2.teamService.getTeamInfo(teamId, teamType)
TypeScriptconst teamId = "123456"
const teamType: V2NIMTeamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL
try {
const team: V2NIMTeam = await nim.teamService.getTeamInfo(teamId, teamType)
// success
} catch (error) {
// fail
}
返回参数
无返回值。
Promise<V2NIMTeam
> 群组信息
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调,包含V2NIMTeam
。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
- 请求成功,返回
V2NIMTeamInfoCallback
回调,可自定义设置。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
getTeamInfoByIds
接口描述
根据群组 ID 批量获取最多 10 个群组的信息列表(包含已退出或已被解散的群组)。
SDK 获取策略如下:

群组数据同步(V2NIMTeamListener.onSyncFinished
)完成前,可能获取不到完整数据。
参数说明
Javavoid getTeamInfoByIds(List<String> teamIds, V2NIMTeamType teamType,V2NIMSuccessCallback<List<V2NIMTeam>> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamIds |
List |
是 | 群组 ID 列表,不能超过 10 个群组 ID。该参数不可为空,否则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
success |
V2NIMSuccessCallback |
是 | 获取成功回调,返回 List<V2NIMTeam >。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
Objective-C- (void)getTeamInfoByIds:(NSArray<NSString *> *)teamIds
teamType:(V2NIMTeamType)teamType
success:(nullable V2NIMTeamInfoListCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamIds |
NSArray<NSString *> * | 是 | 群组 ID 列表,不能超过 10 个群组 ID。该参数不可为空,否则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
success |
V2NIMTeamInfoListCallback |
是 | 获取成功回调,可自定义设置。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
C++virtual void getTeamInfoByIds(std::vector<std::string> teamIds,
V2NIMTeamType teamType,
V2NIMSuccessCallback<std::vector<V2NIMTeam>> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamIds |
std::vectorstd::string | 是 | 群组 ID 列表,不能超过 10 个群组 ID。该参数不可为空,否则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
success |
V2NIMSuccessCallback |
是 | 获取成功回调,返回 std::vector<V2NIMTeam >。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
TypeScriptgetTeamInfoByIds(teamIds: string[], teamType: V2NIMTeamType): Promise<V2NIMTeam[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamIds |
string[] | 是 | 群组 ID 列表,不能超过 10 个群组 ID。该参数不可为空,否则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
TypeScriptgetTeamInfoByIds(teamIds, teamType): Promise<V2NIMTeam[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamIds |
string[] | 是 | 群组 ID 列表,不能超过 10 个群组 ID。该参数不可为空,否则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
TypeScriptgetTeamInfoByIds(teamIds: string[], teamType: V2NIMTeamType): Promise<V2NIMTeam[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamIds |
string[] | 是 | 群组 ID 列表,不能超过 10 个群组 ID。该参数不可为空,否则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
List<String> teamIds = new ArrayList<>();
teamIds.add("123456");
teamIds.add("654321");
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
v2TeamService.getTeamInfoByIds(teamIds,teamType, result -> {
// 根据群组 ID 获取群组信息成功
}, error -> {
// 根据群组 ID 获取群组信息失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService]getTeamInfoByIds:@[@"teamId1",@"teamId2"] teamType:V2NIM_TEAM_TYPE_NORMAL success:^(NSArray<V2NIMTeam *> * _Nonnull teamList) {
// 根据群组 ID 获取群组信息成功
} failure:^(V2NIMError * _Nonnull error) {
// 根据群组 ID 获取群组信息失败
}];
C++nstd::vector<nstd::string> teamIds;
teamIds.push_back("teamId1");
teamIds.push_back("teamId2");
teamService.getTeamInfoByIds(
teamIds,
V2NIM_TEAM_TYPE_NORMAL,
[](nstd::vector<V2NIMTeam> teamList) {
// get team info success
},
[](V2NIMError error) {
// get team info failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.getTeamInfoByIds(["123456"], 1)
TypeScriptconst teams = await v2.teamService.getTeamInfoByIds(teamIds, teamType)
TypeScriptconst teamIds = ["123456", "7890"]
const teamType: V2NIMTeamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL
try {
const teams: V2NIMTeam[] = await nim.teamService.getTeamInfoByIds(teamIds, teamType)
// success
} catch (error) {
// fail
}
返回参数
无返回值。
Promise<V2NIMTeam
[]> 群组信息列表
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调,包含V2NIMTeam
列表。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
- 请求成功,返回
V2NIMTeamInfoListCallback
回调,可自定义设置。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
dismissTeam
接口描述
解散指定群组。
本地端或多端同步解散群组成功后:
- 本地端 SDK 会返回删除成功回调
onTeamDismissed
。 - 群组内所有成员会收到通知消息,通知消息类型为
V2NIMMessageNotificationType.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_DISMISS(4)
。
仅允许群主调用该接口,否则返回错误码 109427。
参数说明
Javavoid dismissTeam(String teamId, V2NIMTeamType teamType,V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
success |
V2NIMSuccessCallback |
是 | 解散群组成功回调。 |
failure |
V2NIMFailureCallback |
是 | 解散群组失败回调,返回 错误码。 |
Objective-C- (void)dismissTeam:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString * | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
success |
V2NIMSuccessCallback |
是 | 解散群组成功回调。 |
failure |
V2NIMFailureCallback |
是 | 解散群组失败回调,返回 错误码。 |
C++virtual void dismissTeam(nstd::string teamId, V2NIMTeamType teamType, V2NIMSuccessCallback<void> success, V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
nstd::string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
success |
V2NIMSuccessCallback |
是 | 解散群组成功回调。 |
failure |
V2NIMFailureCallback |
是 | 解散群组失败回调,返回 错误码。 |
TypeScriptdismissTeam(teamId: string, teamType: V2NIMTeamType): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
TypeScriptdismissTeam(teamId, teamType): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
TypeScriptdismissTeam(teamId: string, teamType: V2NIMTeamType): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
String teamId = "123456";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
v2TeamService.dismissTeam(teamId,teamType, result -> {
// 解散群组成功
}, error -> {
// 解散群组失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] dismissTeam:@"teamId" teamType:V2NIM_TEAM_TYPE_NORMAL success:^{
// 解散群组成功
} failure:^(V2NIMError * _Nonnull error) {
// 解散群组失败
}];
C++teamService.dismissTeam(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
[]() {
// dismiss team success
},
[](V2NIMError error) {
// dismiss team failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.dismissTeam("123456", 1)
TypeScriptawait v2.teamService.dismissTeam(teamId, teamType)
TypeScriptconst teamId = "123456"
const teamType: V2NIMTeamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL
try {
await nim.teamService.dismissTeam(teamId, teamType)
// success
} catch (error) {
// fail
}
返回参数
无返回值。
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。解散成功,返回onTeamDismissed
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
删除成功,返回 onTeamDismissed
回调。
删除成功,返回 teamDismissed
回调。
inviteMemberEx
接口描述
邀请用户加入群组。
较 inviteMember
方法入参新增 V2NIMTeamInviteParams.serverExtension
扩展字段,请优先使用本接口。
本地端或多端同步邀请成功后,群组内其他成员收到一条通知类消息,类型为 V2NIMMessageNotificationType.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_INVITE
。根据创建群组时设置的被邀请方同意模式,有以下回调场景:
V2NIMTeam.agreeMode
为 0:即需要被邀请方同意后加入群,则被邀请方收到邀请入群回调onReceiveTeamJoinActionInfo
。V2NIMTeam.agreeMode
为 1:即不需要被邀请方同意,则被邀请方直接加入群组,此时被邀请方收到onTeamJoined
回调,其他群成员收到onTeamMemberJoined
回调。
参数说明
Javavoid com.netease.nimlib.sdk.v2.team.V2NIMTeamService.inviteMemberEx(
String teamId,
V2NIMTeamType teamType,
V2NIMTeamInviteParams inviteeParams,
V2NIMSuccessCallback<List<String>> success,
V2NIMFailureCallback failure
)
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
inviteeParams |
V2NIMTeamInviteParams |
是 | 被邀请入群的配置参数。不可为空,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
是 | 邀请入群成功回调,返回邀请失败的用户账号列表。 |
failure |
V2NIMFailureCallback |
是 | 邀请入群失败回调,返回 错误码。 |
Objective-C- (void)inviteMemberEx:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
inviteeParams:(V2NIMTeamInviteParams *)inviteeParams
success:(nullable V2NIMTeamInviteMemberCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString * | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
inviteeParams |
V2NIMTeamInviteParams |
是 | 被邀请入群的配置参数。不可为空,否则返回 191004 参数错误。 |
success |
V2NIMTeamInviteMemberCallback |
是 | 邀请入群成功回调,可自定义设置。 |
failure |
V2NIMFailureCallback |
是 | 邀请入群失败回调,返回 错误码。 |
C++virtual void v2::V2NIMTeamService::inviteMemberEx(
nstd::string teamId,
V2NIMTeamType teamType,
V2NIMTeamInviteParams inviteeParams,
V2NIMSuccessCallback<nstd::vector<nstd::string>> success,
V2NIMFailureCallback failure
)
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
nstd::string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
inviteeParams |
V2NIMTeamInviteParams |
是 | 被邀请入群的配置参数。不可为空,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
是 | 邀请入群成功回调,返回邀请失败的用户账号列表。 |
failure |
V2NIMFailureCallback |
是 | 邀请入群失败回调,返回 错误码。 |
TypeScriptinviteMemberEx(teamId: string, teamType: V2NIMTeamType, inviteeParams: V2NIMTeamInviteeParams): Promise<string[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
inviteeParams |
V2NIMTeamInviteParams |
是 | 被邀请入群的配置参数。不可为空,否则返回 191004 参数错误。 |
TypeScriptinviteMemberEx(teamId, teamType, inviteeParams): Promise<string[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
inviteeParams |
V2NIMTeamInviteParams |
是 | 被邀请入群的配置参数。不可为空,否则返回 191004 参数错误。 |
TypeScriptinviteMemberEx(teamId: string, teamType: V2NIMTeamType, inviteeParams: V2NIMTeamInviteParams): Promise<string[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
inviteeParams |
V2NIMTeamInviteParams |
是 | 被邀请入群的配置参数。不可为空,否则返回 191004 参数错误。 |
示例代码
JavaString teamId = "123";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
List<String> inviteeAccountIds = Arrays.asList("aaa", "bbb");
String postscript = "postscript";
String serverExtension = "serverExtension";
V2NIMTeamInviteParams inviteParams = new V2NIMTeamInviteParams();
inviteParams.setInviteeAccountIds(inviteeAccountIds);
inviteParams.setPostscript(postscript);
inviteParams.setServerExtension(serverExtension);
// 调用接口
NIMClient.getService(V2NIMTeamService.class).inviteMemberEx(teamId, teamType, inviteParams,
new V2NIMSuccessCallback<List<String>>() {
@Override
public void onSuccess(List<String> param) {
System.out.println("Invite member success");
if (!param.isEmpty()) {
System.out.println("Failed to invite members: " + param);
}
}
},
new V2NIMFailureCallback() {
@Override
public void onFailure(V2NIMError error) {
System.out.println("Invite member failed, code: " + error.getCode() + ", message: " + error.getMessage());
}
}
);
Objective-CNSString *teamId = @"123";
V2NIMTeamType teamType = V2NIM_TEAM_TYPE_NORMAL;
NSArray<NSString *> *inviteeAccountIds = @[@"aaa", @"bbb"];
NSString *postscript = @"postscript";
NSString *serverExtension = @"serverExtension";
V2NIMTeamInviteParams *inviteParams = [[V2NIMTeamInviteParams alloc] init];
[inviteParams setInviteeAccountIds:inviteeAccountIds];
[inviteParams setPostscript:postscript];
[inviteParams setServerExtension:serverExtension];
[[NIMSDK sharedSDK].v2TeamService inviteMemberEx:teamId teamType:teamType inviteeParams:inviteParams success:^(NSArray<NSString *> * _Nonnull failedList)
{
if (failedList.count > 0)
{
NSLog(@"InviteMemberEx partially success. Failed account ids: %@", failedList);
} else
{
NSLog(@"InviteMemberEx success");
}
} failure:^(V2NIMError * _Nonnull error)
{
NSLog(@"Invite member failed. error: %@", error);
}];
C++nstd::vector<nstd::string> inviteeAccountIds;
inviteeAccountIds.push_back("account1");
V2NIMTeamInviteParams inviteeParams;
inviteeParams.inviteeAccountIds = inviteeAccountIds;
inviteeParams.postscript = "postscript";
inviteeParams.serverExtension = "serverExtension";
teamService.inviteMemberEx(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
inviteeParams,
[](nstd::vector<nstd::string> failedList) {
// invite member success
},
[](V2NIMError error) {
// invite member failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.inviteMemberEx("123456", 1, { inviteeAccountIds: ["accountId1"] })
TypeScriptconst accountIds = await v2.teamService.inviteMemberEx(teamId, teamType, inviteeParams)
TypeScript// input
const teamId: string = this.teamId
const teamType: V2NIMTeamType = this.teamType
const inviteeAccountIds: string[] = this.inviteeAccountIds.split(',') // 以 ',' 分割
const postscript: string | undefined = this.postscript
const serverExtension: string | undefined = this.serverExtension
const inviteeParams: V2NIMTeamInviteParams = {
inviteeAccountIds,
postscript,
serverExtension
}
// call interface
const res = await teamService.inviteMemberEx(teamId, teamType, inviteeParams)
返回参数
无返回值。
Promise<string[]> 邀请失败的用户账号(accountId)列表
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调,包含邀请失败的用户账号(accountId)列表。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
- 请求成功,返回
V2NIMTeamInviteMemberCallback
回调,包含邀请失败的用户账号(accountId)列表,可自定义设置。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
inviteMember
接口描述
邀请用户加入群组。
本地端或多端同步邀请成功后,群组内其他成员收到一条通知类消息,类型为 V2NIMMessageNotificationType.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_INVITE
。根据创建群组时设置的被邀请方同意模式,有以下回调场景:
V2NIMTeam.agreeMode
为 0:即需要被邀请方同意后加入群,则被邀请方收到邀请入群回调onReceiveTeamJoinActionInfo
。V2NIMTeam.agreeMode
为 1:即不需要被邀请方同意,则被邀请方直接加入群组,此时被邀请方收到onTeamJoined
回调,其他群成员收到onTeamMemberJoined
回调。
参数说明
Javavoid inviteMember(String teamId, V2NIMTeamType teamType, List<String> inviteeAccountIds, String postscript,V2NIMSuccessCallback<List<String>> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
inviteeAccountIds |
List |
是 | 被邀请入群的用户账号列表。不可为空,否则返回 191004 参数错误。 |
postscript |
String | 否 | 邀请入群附言。 |
success |
V2NIMSuccessCallback |
是 | 邀请入群成功回调,返回邀请失败的用户账号列表。 |
failure |
V2NIMFailureCallback |
是 | 邀请入群失败回调,返回 错误码。 |
Objective-C- (void)inviteMember:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
inviteeAccountIds:(NSArray<NSString *> *)inviteeAccountIds
postscript:(nullable NSString *)postscript
success:(nullable V2NIMTeamInviteMemberCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString * | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
inviteeAccountIds |
NSArray<NSString *> * | 是 | 被邀请入群的用户账号列表。不可为空,否则返回 191004 参数错误。 |
postscript |
NSString * | 否 | 邀请入群附言。 |
success |
V2NIMTeamInviteMemberCallback |
是 | 邀请入群成功回调,可自定义设置。 |
failure |
V2NIMFailureCallback |
是 | 邀请入群失败回调,返回 错误码。 |
C++virtual void inviteMember(nstd::string teamId,
V2NIMTeamType teamType,
nstd::vector<nstd::string> inviteeAccountIds,
nstd::string postscript,
V2NIMSuccessCallback<nstd::vector<nstd::string>> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
nstd::string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
inviteeAccountIds |
nstd::vectornstd::string | 是 | 被邀请入群的用户账号列表。不可为空,否则返回 191004 参数错误。 |
postscript |
nstd::string | 否 | 邀请入群附言。 |
success |
V2NIMSuccessCallback |
是 | 邀请入群成功回调,返回邀请失败的用户账号列表。 |
failure |
V2NIMFailureCallback |
是 | 邀请入群失败回调,返回 错误码。 |
TypeScriptinviteMember(teamId: string, teamType: V2NIMTeamType, inviteeAccountIds: string[], postscript?: string): Promise<string[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
inviteeAccountIds |
string[] | 是 | 被邀请入群的用户账号列表。不可为空,否则返回 191004 参数错误。 |
postscript |
string | 否 | 邀请入群附言。 |
TypeScriptinviteMember(teamId, teamType, inviteeAccountIds, postscript): Promise<string[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
inviteeAccountIds |
string[] | 是 | 被邀请入群的用户账号列表。不可为空,否则返回 191004 参数错误。 |
postscript |
string | 否 | 邀请入群附言。 |
TypeScriptinviteMember(teamId: string, teamType: V2NIMTeamType, inviteeAccountIds: string[], postscript?: string): Promise<string[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
inviteeAccountIds |
string[] | 是 | 被邀请入群的用户账号列表。不可为空,否则返回 191004 参数错误。 |
postscript |
string | 否 | 邀请入群附言。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
String teamId = "123456";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
List<String> inviteeAccountIds = new ArrayList<>();
inviteeAccountIds.add("test1");
inviteeAccountIds.add("test2");
String postscript = "test";
v2TeamService.inviteMember(teamId,teamType, inviteeAccountIds, postscript, result -> {
// 邀请成员加入群组成功
}, error -> {
// 邀请成员加入群组失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] inviteMember:@"teamId" teamType:V2NIM_TEAM_TYPE_NORMAL inviteeAccountIds:@[@"accountId1"] postscript:@"test" success:^(NSArray<NSString *> * _Nonnull failedList) {
// 邀请成员加入群组成功
} failure:^(V2NIMError * _Nonnull error) {
// 邀请成员加入群组失败
}];
C++nstd::vector<nstd::string> inviteeAccountIds;
inviteeAccountIds.push_back("account1");
teamService.inviteMember(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
inviteeAccountIds,
"postscript",
[](nstd::vector<nstd::string> failedList) {
// invite member success
},
[](V2NIMError error) {
// invite member failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.inviteMember("123456", 1, ["accountId1"])
TypeScriptconst accountIds = await v2.teamService.inviteMember("123456", 1, ["accountId1"])
TypeScripttry {
const teamId: string = "123456"
const teamType: V2NIMTeamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL
const inviteeAccountIds: string[] = ["acc1", "acc2"]
const postscript: string | undefined = "postscript"
const res = await teamService.inviteMember(teamId, teamType, inviteeAccountIds, postscript)
// success
}
catch (err) {
// fail
}
返回参数
无返回值。
Promise<string[]> 邀请失败的用户账号(accountId)列表
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调,包含邀请失败的用户账号(accountId)列表。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
- 请求成功,返回
V2NIMTeamInviteMemberCallback
回调,包含邀请失败的用户账号(accountId)列表,可自定义设置。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
acceptInvitation
接口描述
接受入群邀请。
本地端或多端同步接受入群邀请成功后:
- 本地端收到加入群组成功回调
onTeamJoined
。 - 群组内其他成员收到一条通知类消息,类型为
V2NIMMessageNotificationType.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_INVITE_ACCEPT
。收到其他用户加入群组回调onTeamMemberJoined
。
参数说明
Javavoid acceptInvitation(V2NIMTeamJoinActionInfo invitationInfo,V2NIMSuccessCallback<V2NIMTeam> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
invitationInfo |
V2NIMTeamJoinActionInfo |
是 | 邀请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION ,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
否 | 接受入群邀请成功回调,返回 V2NIMTeam 。 |
failure |
V2NIMFailureCallback |
是 | 接受入群邀请失败回调,返回 错误码。 |
Objective-C- (void)acceptInvitation:(V2NIMTeamJoinActionInfo *)invitationInfo
success:(nullable V2NIMTeamInfoCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
invitationInfo |
V2NIMTeamJoinActionInfo |
是 | 邀请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION ,否则返回 191004 参数错误。 |
success |
V2NIMTeamInfoCallback |
是 | 接受入群邀请成功回调,返回 V2NIMTeam ,可自定义设置。 |
failure |
V2NIMFailureCallback |
是 | 接受入群邀请失败回调,返回 错误码。 |
C++virtual void acceptInvitation(V2NIMTeamJoinActionInfo invitationInfo, V2NIMSuccessCallback<V2NIMTeam> success, V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
invitationInfo |
V2NIMTeamJoinActionInfo |
是 | 邀请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION ,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
否 | 接受入群邀请成功回调,返回 V2NIMTeam 。 |
failure |
V2NIMFailureCallback |
是 | 接受入群邀请失败回调,返回 错误码。 |
TypeScriptacceptInvitation(invitationInfo: V2NIMTeamJoinActionInfo): Promise<V2NIMTeam>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
invitationInfo |
V2NIMTeamJoinActionInfo |
是 | 邀请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION ,否则返回 191004 参数错误。 |
TypeScriptacceptInvitation(invitationInfo): Promise<V2NIMTeam>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
invitationInfo |
V2NIMTeamJoinActionInfo |
是 | 邀请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION ,否则返回 191004 参数错误。 |
TypeScriptacceptInvitation(invitationInfo: V2NIMTeamJoinActionInfo): Promise<V2NIMTeam>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
invitationInfo |
V2NIMTeamJoinActionInfo |
是 | 邀请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION ,否则返回 191004 参数错误。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
// 收到的邀请信息
V2NIMTeamJoinActionInfo invitationInfo = getInvitationInfo();
v2TeamService.acceptInvitation(invitationInfo, result -> {
// 同意邀请入群成功
}, error -> {
// 同意邀请入群失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] acceptInvitation:invitationInfo success:^(V2NIMTeam * _Nonnull team) {
// 同意邀请入群成功
} failure:^(V2NIMError * _Nonnull error) {
// 同意邀请入群失败
}];
C++V2NIMTeamJoinActionInfo invitationInfo;
// get invitationInfo from notification or query
// ...
teamService.acceptInvitation(
invitationInfo,
[](V2NIMTeam team) {
// accept invitation success
},
[](V2NIMError error) {
// accept invitation failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.acceptInvitation(
{
"teamId": "123456",
"teamType": 1,
"operatorAccountId": "accountId1",
"actionType": 2
}
)
TypeScriptconst team = await v2.teamService.acceptInvitation(
{
"teamId": "123456",
"teamType": 1,
"operatorAccountId": "accountId1",
"actionType": 2
}
)
TypeScripttry{
const invitationInfo: V2NIMTeamJoinActionInfo = {
actionType: V2NIMTeamJoinActionType.V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION,
teamId: "123456",
teamType: V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL,
operatorAccountId: "account1",
}
const team: V2NIMTeam = await nim.teamService.acceptInvitation(invitationInfo)
// success
}
catch (err) {
// fail
}
返回参数
无返回值。
Promise<V2NIMTeam
>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调,包含V2NIMTeam
。接受入群邀请成功,收到加入群组成功回调onTeamJoined
。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
- 请求成功,返回
V2NIMTeamInfoCallback
回调,可自定义设置。接受入群邀请成功,收到加入群组成功回调onTeamJoined
。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
rejectInvitation
接口描述
拒绝入群邀请。
本地端或多端拒绝入群邀请成功后,群主和群管理员收到 onReceiveTeamJoinActionInfo
回调,V2NIMTeamJoinActionType
为 V2NIM_TEAM_JOIN_ACTION_TYPE_REJECT_INVITATION(3)
。
参数说明
Javavoid rejectInvitation(V2NIMTeamJoinActionInfo invitationInfo, String postscript,V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
invitationInfo |
V2NIMTeamJoinActionInfo |
是 | 邀请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION ,否则返回 191004 参数错误。 |
postscript |
String | 否 | 拒绝邀请附言。 |
success |
V2NIMSuccessCallback |
否 | 拒绝入群邀请成功回调。 |
failure |
V2NIMFailureCallback |
是 | 拒绝入群邀请失败回调,返回 错误码。 |
Objective-C- (void)rejectInvitation:(V2NIMTeamJoinActionInfo *)invitationInfo
postscript:(nullable NSString *)postscript
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
invitationInfo |
V2NIMTeamJoinActionInfo |
是 | 邀请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION ,否则返回 191004 参数错误。 |
postscript |
NSString * | 否 | 拒绝邀请附言。 |
success |
V2NIMSuccessCallback |
否 | 拒绝入群邀请成功回调。 |
failure |
V2NIMFailureCallback |
是 | 拒绝入群邀请失败回调,返回 错误码。 |
C++virtual void rejectInvitation(V2NIMTeamJoinActionInfo invitationInfo,
std::string postscript,
V2NIMSuccessCallback<void> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
invitationInfo |
V2NIMTeamJoinActionInfo |
是 | 邀请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION ,否则返回 191004 参数错误。 |
postscript |
std::string | 否 | 拒绝邀请附言。 |
success |
V2NIMSuccessCallback |
否 | 拒绝入群邀请成功回调。 |
failure |
V2NIMFailureCallback |
是 | 拒绝入群邀请失败回调,返回 错误码。 |
TypeScriptrejectInvitation(invitationInfo: V2NIMTeamJoinActionInfo, postscript?: string): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
invitationInfo |
V2NIMTeamJoinActionInfo |
是 | 邀请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION ,否则返回 191004 参数错误。 |
postscript |
string | 否 | 拒绝邀请附言。 |
TypeScriptrejectInvitation(invitationInfo, postscript): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
invitationInfo |
V2NIMTeamJoinActionInfo |
是 | 邀请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION ,否则返回 191004 参数错误。 |
postscript |
string | 否 | 拒绝邀请附言。 |
TypeScriptrejectInvitation(invitationInfo: V2NIMTeamJoinActionInfo, postscript?: string): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
invitationInfo |
V2NIMTeamJoinActionInfo |
是 | 邀请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION ,否则返回 191004 参数错误。 |
postscript |
string | 否 | 拒绝邀请附言。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
// 收到的邀请信息
V2NIMTeamJoinActionInfo invitationInfo = getInvitationInfo();
String postscript = "test";
v2TeamService.rejectInvitation(invitationInfo, postscript, result -> {
// 拒绝邀请入群成功
}, error -> {
// 拒绝邀请入群失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] rejectInvitation:invitationInfo postscript:@"test" success:^{
// 拒绝邀请入群成功
} failure:^(V2NIMError * _Nonnull error) {
// 拒绝邀请入群失败
}];
C++V2NIMTeamJoinActionInfo invitationInfo;
// get invitationInfo from notification or query
// ...
teamService.rejectInvitation(
invitationInfo,
"postscript",
[]() {
// reject invitation success
},
[](V2NIMError error) {
// reject invitation failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.rejectInvitation(
{
"teamId": "123456",
"teamType": 1,
"operatorAccountId": "accountId1",
"actionType": 2
},
"test postscript"
)
TypeScriptawait v2.teamService.rejectInvitation(
{
"teamId": "123456",
"teamType": 1,
"operatorAccountId": "accountId1",
"actionType": 2
},
"test postscript"
)
TypeScripttry{
const invitationInfo: V2NIMTeamJoinActionInfo = {
actionType: V2NIMTeamJoinActionType.V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION,
teamId: "123456",
teamType: V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL,
operatorAccountId: "account1",
}
await nim.teamService.rejectInvitation(invitationInfo)
// success
}
catch (err) {
// fail
}
返回参数
无返回值。
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
kickMember
接口描述
批量将群组成员踢出群组。
本地端或多端同步踢出群组成员成功后:
- 被踢方收到离开群组回调
onTeamLeft
。 - 群组内所有成员收到一条通知类消息,类型为
V2NIMMessageNotificationType.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_KICK
。收到群成员被踢回调onTeamMemberKicked
。
- 只有群主和管理员才能将成员踢出群组。
- 管理员不能踢群主和其他管理员。
参数说明
Javavoid kickMember(String teamId, V2NIMTeamType teamType, List<String> memberAccountIds, V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
memberAccountIds |
List |
是 | 踢出群组的成员账号(accountId)列表,不可为空,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
是 | 踢出成功回调。 |
failure |
V2NIMFailureCallback |
是 | 踢出失败回调,返回 错误码。 |
Objective-C- (void)kickMember:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
memberAccountIds:(nullable NSArray<NSString *> *)memberAccountIds
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString * | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
memberAccountIds |
NSArray<NSString *> * | 是 | 踢出群组的成员账号(accountId)列表,不可为空,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
是 | 踢出成功回调。 |
failure |
V2NIMFailureCallback |
是 | 踢出失败回调,返回 错误码。 |
C++virtual void kickMember(nstd::string teamId,
V2NIMTeamType teamType,
nstd::vector<nstd::string> memberAccountIds,
V2NIMSuccessCallback<void> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
nstd::string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
memberAccountIds |
nstd::vectornstd::string | 是 | 踢出群组的成员账号(accountId)列表,不可为空,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
是 | 踢出成功回调。 |
failure |
V2NIMFailureCallback |
是 | 踢出失败回调,返回 错误码。 |
TypeScriptkickMember(teamId: string, teamType: V2NIMTeamType, memberAccountIds: string[]): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
memberAccountIds |
string[] | 是 | 踢出群组的成员账号(accountId)列表,不可为空,否则返回 191004 参数错误。 |
TypeScriptkickMember(teamId, teamType, memberAccountIds): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
memberAccountIds |
string[] | 是 | 踢出群组的成员账号(accountId)列表,不可为空,否则返回 191004 参数错误。 |
TypeScriptkickMember(teamId: string, teamType: V2NIMTeamType, memberAccountIds: string[]): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
memberAccountIds |
string[] | 是 | 踢出群组的成员账号(accountId)列表,不可为空,否则返回 191004 参数错误。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
String teamId = "123456";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
List<String> memberAccountIds = new ArrayList<>();
memberAccountIds.add("test1");
memberAccountIds.add("test2");
v2TeamService.kickMember(teamId,teamType, memberAccountIds, result -> {
// 踢出群组成员成功
}, error -> {
// 踢出群组成员失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] kickMember:@"teamId" teamType:V2NIM_TEAM_TYPE_NORMAL memberAccountIds:@[@"accountId1"] success:^{
// 踢出群组成员成功
} failure:^(V2NIMError * _Nonnull error) {
// 踢出群组成员失败
}];
C++nstd::vector<nstd::string> memberAccountIds;
memberAccountIds.push_back("account1");
teamService.kickMember(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
memberAccountIds,
[]() {
// kick member success
},
[](V2NIMError error) {
// kick member failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.kickMember("123456", 1, ["accountId1"])
TypeScriptawait v2.teamService.kickMember(teamId, teamType, memberAccountIds)
TypeScripttry{
const teamId = "123456",
const teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL,
const accounts = ["aaa", "bbb"]
await nim.teamService.kickMember(teamId, teamType, accounts)
// success
}
catch (err) {
// fail
}
返回参数
无返回值。
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。踢出群组成功,返回onTeamMemberKicked
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
踢出群组成功,返回 onTeamMemberKicked
回调。
踢出群组成功,返回 teamMemberKicked
回调。
applyJoinTeam
接口描述
申请加入群组。
本地端或多端同步申请加入群组成功后,根据创建群组时设置的入群验证模式,有以下回调场景:
V2NIMTeam.joinMode
为 0:即无需验证直接加入群组,此时本端收到加入群组回调onTeamJoined
,其他群成员收到群成员入群回调onTeamMemberJoined
和群信息更新回调onTeamInfoUpdated
。V2NIMTeam.joinMode
为 1:即需要群主或管理员验证同意后加入群,则群主和管理员收到onReceiveTeamJoinActionInfo
回调,V2NIMTeamJoinActionType
为V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION(0)
V2NIMTeam.joinMode
为 2:即私有群,该模式不支持入群申请,仅能通过邀请方式入群,此时 SDK 不会触发任何回调。
参数说明
Javavoid applyJoinTeam(String teamId, V2NIMTeamType teamType, String postscript,V2NIMSuccessCallback<V2NIMTeam> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
postscript |
String | 否 | 申请入群附言。 |
success |
V2NIMSuccessCallback |
否 | 申请入群成功回调,包含 V2NIMTeam 。 |
failure |
V2NIMFailureCallback |
是 | 申请入群失败回调,返回 错误码。 |
Objective-C- (void)applyJoinTeam:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
postscript:(nullable NSString *)postscript
success:(nullable V2NIMTeamInfoCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString * | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
postscript |
NSString * | 否 | 申请入群附言。 |
success |
V2NIMTeamInfoCallback |
否 | 申请入群成功回调,包含 V2NIMTeam ,可自定义设置。 |
failure |
V2NIMFailureCallback |
是 | 申请入群失败回调,返回 错误码。 |
C++virtual void applyJoinTeam(nstd::string teamId,
V2NIMTeamType teamType,
nstd::string postscript,
V2NIMSuccessCallback<V2NIMTeam> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
nstd::string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
postscript |
nstd::string | 否 | 申请入群附言。 |
success |
V2NIMSuccessCallback |
否 | 申请入群成功回调,包含 V2NIMTeam 。 |
failure |
V2NIMFailureCallback |
是 | 申请入群失败回调,返回 错误码。 |
TypeScriptapplyJoinTeam(teamId: string, teamType: V2NIMTeamType, postscript?: string): Promise<V2NIMTeam>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
postscript |
string | 否 | 申请入群附言。 |
TypeScriptapplyJoinTeam(teamId, teamType, postscript): Promise<V2NIMTeam>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
postscript |
string | 否 | 申请入群附言。 |
TypeScriptapplyJoinTeam(teamId: string, teamType: V2NIMTeamType, postscript?: string): Promise<V2NIMTeam>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
postscript |
string | 否 | 申请入群附言。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
String teamId = "123456";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
String postscript = "test";
v2TeamService.applyJoinTeam(teamId, teamType, postscript, result -> {
// 申请加入群组成功
}, error -> {
// 申请加入群组失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] applyJoinTeam:@"teamId" teamType:V2NIM_TEAM_TYPE_NORMAL postscript:@"test" success:^(V2NIMTeam * _Nonnull team) {
// 申请加入群组成功
} failure:^(V2NIMError * _Nonnull error) {
// 申请加入群组失败
}];
C++teamService.applyJoinTeam(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
"postscript",
[](V2NIMTeam team) {
// apply join team success
},
[](V2NIMError error) {
// apply join team failed, handle error
}
);
TypeScriptawait nim.V2NIMTeamService.applyJoinTeam("123456", 1, "test postscript")
TypeScriptconst team = await v2.teamService.applyJoinTeam(teamId, teamType, postscript)
TypeScripttry{
const teamId = "123456",
const teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL,
const postscript = "postscript"
await nim.teamService.applyJoinTeam(teamId, teamType, postscript)
// success
}
catch (err) {
// fail
}
返回参数
无返回值。
Promise<V2NIMTeam
>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调,包含V2NIMTeam
。加入群组成功,返回onTeamJoined
- 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
- 请求成功,返回
V2NIMTeamInfoCallback
回调,可自定义设置。加入群组成功,返回onTeamJoined
。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
acceptJoinApplication
接口描述
同意入群申请。
本地端或多端同步同意入群申请成功后:
- 群主和群管理员收到一条通知类消息,类型为
V2NIMMessageNotificationType .V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_APPLY_PASS
。 - 申请方加入群组,收到加入群组成功回调
onTeamJoined
。群组内所有成员收到群成员入群回调onTeamMemberJoined
和群信息更新回调onTeamInfoUpdated
。
仅允许群主或管理员调用该接口,否则返回错误码 109432。
参数说明
Javavoid acceptJoinApplication(V2NIMTeamJoinActionInfo applicationInfo,V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
是 | 申请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION ,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
是 | 同意入群申请成功回调。 |
failure |
V2NIMFailureCallback |
是 | 同意入群申请失败回调,返回 错误码。 |
Objective-C- (void)acceptJoinApplication:(V2NIMTeamJoinActionInfo *)applicationInfo
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
是 | 申请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION ,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
是 | 同意入群申请成功回调。 |
failure |
V2NIMFailureCallback |
是 | 同意入群申请失败回调,返回 错误码。 |
C++virtual void acceptJoinApplication(V2NIMTeamJoinActionInfo applicationInfo, V2NIMSuccessCallback<void> success, V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
是 | 申请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION ,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
是 | 同意入群申请成功回调。 |
failure |
V2NIMFailureCallback |
是 | 同意入群申请失败回调,返回 错误码。 |
TypeScriptacceptJoinApplication(applicationInfo: V2NIMTeamJoinActionInfo): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
是 | 申请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION ,否则返回 191004 参数错误。 |
TypeScriptacceptJoinApplication(applicationInfo): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
是 | 申请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION ,否则返回 191004 参数错误。 |
TypeScriptacceptJoinApplication(applicationInfo: V2NIMTeamJoinActionInfo): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
是 | 申请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION ,否则返回 191004 参数错误。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
// 收到的入群申请信息
V2NIMTeamJoinActionInfo applicationInfo = getApplicationInfo();
v2TeamService.acceptJoinApplication(applicationInfo, result -> {
// 接受入群申请成功
}, error -> {
// 接受入群申请失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] acceptJoinApplication:info success:^{
// 接受入群申请成功
} failure:^(V2NIMError * _Nonnull error) {
// 接受入群申请失败
}];
C++V2NIMTeamJoinActionInfo applicationInfo;
// get applicationInfo from notification or query
// ...
teamService.acceptJoinApplication(
applicationInfo,
[]() {
// accept join application success
},
[](V2NIMError error) {
// accept join application failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.acceptJoinApplication(
{
"teamId": "123456",
"teamType": 1,
"operatorAccountId": "accountId1",
"actionType": 0
}
)
TypeScriptawait v2.teamService.acceptJoinApplication(
{
"teamId": "123456",
"teamType": 1,
"operatorAccountId": "accountId1",
"actionType": 0
}
)
TypeScripttry{
const applicationInfo: V2NIMTeamJoinActionInfo = {
actionType: V2NIMTeamJoinActionType.V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION,
teamId: "123456",
teamType: V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL,
operatorAccountId: "account1",
}
await nim.teamService.acceptJoinApplication(applicationInfo)
// success
}
catch (err) {
// fail
}
返回参数
无返回值。
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
rejectJoinApplication
接口描述
拒绝入群申请。
本地端或多端同步拒绝入群申请成功后:
入群申请方收到 onReceiveTeamJoinActionInfo
回调,V2NIMTeamJoinActionType
为 V2NIM_TEAM_JOIN_ACTION_TYPE_REJECT_APPLICATION(1)
。
仅允许群主或管理员调用该接口,否则返回错误码 109432。
参数说明
Javavoid rejectJoinApplication(V2NIMTeamJoinActionInfo applicationInfo, String postscript,V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
是 | 申请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION ,否则返回 191004 参数错误。 |
postscript |
String | 否 | 拒绝入群申请附言。 |
success |
V2NIMSuccessCallback |
是 | 拒绝入群申请成功回调。 |
failure |
V2NIMFailureCallback |
是 | 拒绝入群申请失败回调,返回 错误码。 |
Objective-C- (void)rejectJoinApplication:(V2NIMTeamJoinActionInfo *)applicationInfo
postscript:(nullable NSString *)postscript
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
是 | 申请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION ,否则返回 191004 参数错误。 |
postscript |
NSString | 否 | 拒绝入群申请附言。 |
success |
V2NIMSuccessCallback |
是 | 拒绝入群申请成功回调。 |
failure |
V2NIMFailureCallback |
是 | 拒绝入群申请失败回调,返回 错误码。 |
C++virtual void rejectJoinApplication(V2NIMTeamJoinActionInfo applicationInfo,
std::string postscript,
V2NIMSuccessCallback<void> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
是 | 申请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION ,否则返回 191004 参数错误。 |
postscript |
std::string | 否 | 拒绝入群申请附言。 |
success |
V2NIMSuccessCallback |
是 | 拒绝入群申请成功回调。 |
failure |
V2NIMFailureCallback |
是 | 拒绝入群申请失败回调,返回 错误码。 |
TypeScriptrejectJoinApplication(applicationInfo: V2NIMTeamJoinActionInfo, postscript?: string): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
是 | 申请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION ,否则返回 191004 参数错误。 |
postscript |
string | 否 | 拒绝入群申请附言。 |
TypeScriptrejectJoinApplication(applicationInfo, postscript): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
是 | 申请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION ,否则返回 191004 参数错误。 |
postscript |
string | 否 | 拒绝入群申请附言。 |
TypeScriptrejectJoinApplication(applicationInfo: V2NIMTeamJoinActionInfo, postscript?: string): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
是 | 申请入群信息。其中 actionType 必须为 V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION ,否则返回 191004 参数错误。 |
postscript |
string | 否 | 拒绝入群申请附言。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
// 收到的入群申请信息
V2NIMTeamJoinActionInfo applicationInfo = getApplicationInfo();
String postscript = "test";
v2TeamService.rejectInvitation(applicationInfo, postscript, result -> {
// 拒绝入群申请成功
}, error -> {
// 拒绝入群申请失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] rejectJoinApplication:info
postscript:@"test"
success:^{
// 拒绝入群申请成功
}
failure:^(V2NIMError * _Nonnull error) {
// 拒绝入群申请失败
}];
C++V2NIMTeamJoinActionInfo applicationInfo;
// get applicationInfo from notification or query
// ...
teamService.rejectJoinApplication(
applicationInfo,
"postscript",
[]() {
// reject join application success
},
[](V2NIMError error) {
// reject join application failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.rejectJoinApplication(
{
"teamId": "123456",
"teamType": 1,
"operatorAccountId": "accountId1",
"actionType": 0
},
"test postscript"
)
TypeScriptawait v2.teamService.rejectJoinApplication(
{
"teamId": "123456",
"teamType": 1,
"operatorAccountId": "accountId1",
"actionType": 0
},
"test postscript"
)
TypeScripttry{
const applicationInfo: V2NIMTeamJoinActionInfo = {
actionType: V2NIMTeamJoinActionType.V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION,
teamId: "123456",
teamType: V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL,
operatorAccountId: "account1",
}
const postscript = "postscript"
await nim.teamService.rejectJoinApplication(applicationInfo, postscript)
// success
}
catch (err) {
// fail
}
返回参数
无返回值。
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
updateTeamMemberRole
接口描述
批量更新群成员角色类型。
本地端或多端同步更新群成员角色类型成功后:
- 群组内所有成员收到群成员信息变更回调
onTeamMemberInfoUpdated
。 - 群主添加管理员后(
blocked
为true
),所有群成员会收到群组通知消息,通知消息类型为V2NIMMessageNotificationType.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_ADD_MANAGER(7)
。群主移除管理员后(修改角色类型为普通成员),所有群成员收到群组通知消息类型为V2NIMMessageNotificationType.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_REMOVE_MANAGER(8)
。
仅允许群主调用该接口,否则返回错误码 109427。
参数说明
Javavoid updateTeamMemberRole(String teamId, V2NIMTeamType teamType, List<String> memberAccountIds, V2NIMTeamMemberRole memberRole,V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
memberAccountIds |
List |
是 | 群成员账号(accountId)列表,不可为空,否则返回 191004 参数错误。 |
memberRole |
V2NIMTeamMemberRole |
是 | 群成员角色类型。仅支持设置为群普通成员或群管理员,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
是 | 更新成功回调。 |
failure |
V2NIMFailureCallback |
是 | 更新失败回调,返回 错误码。 |
Objective-C- (void)updateTeamMemberRole:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
memberAccountIds:(NSArray<NSString *> *)memberAccountIds
memberRole:(V2NIMTeamMemberRole)memberRole
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString * | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
memberAccountIds |
NSArray<NSString *> * | 是 | 群成员账号(accountId)列表,不可为空,否则返回 191004 参数错误。 |
memberRole |
V2NIMTeamMemberRole |
是 | 群成员角色类型。仅支持设置为群普通成员或群管理员,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
是 | 更新成功回调。 |
failure |
V2NIMFailureCallback |
是 | 更新失败回调,返回 错误码。 |
C++virtual void updateTeamMemberRole(nstd::string teamId,
V2NIMTeamType teamType,
nstd::vector<nstd::string> memberAccountId,
V2NIMTeamMemberRole memberRole,
V2NIMSuccessCallback<void> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
nstd::string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
memberAccountIds |
nstd::vector<\nstd::string> | 是 | 群成员账号(accountId)列表,不可为空,否则返回 191004 参数错误。 |
memberRole |
V2NIMTeamMemberRole |
是 | 群成员角色类型。仅支持设置为群普通成员或群管理员,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
是 | 更新成功回调。 |
failure |
V2NIMFailureCallback |
是 | 更新失败回调,返回 错误码。 |
TypeScriptupdateTeamMemberRole(teamId: string, teamType: V2NIMTeamType, memberAccountIds: string[], memberRole: V2NIMTeamMemberRole): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
memberAccountIds |
string[] | 是 | 群成员账号(accountId)列表,不可为空,否则返回 191004 参数错误。 |
memberRole |
V2NIMTeamMemberRole |
是 | 群成员角色类型。仅支持设置为群普通成员或群管理员,否则返回 191004 参数错误。 |
TypeScriptupdateTeamMemberRole(teamId, teamType, memberAccountIds, memberRole): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
memberAccountIds |
string[] | 是 | 群成员账号(accountId)列表,不可为空,否则返回 191004 参数错误。 |
memberRole |
V2NIMTeamMemberRole |
是 | 群成员角色类型。仅支持设置为群普通成员或群管理员,否则返回 191004 参数错误。 |
TypeScriptupdateTeamMemberRole(teamId: string, teamType: V2NIMTeamType, memberAccountIds: string[], memberRole: V2NIMTeamMemberRole): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
memberAccountIds |
string[] | 是 | 群成员账号(accountId)列表,不可为空,否则返回 191004 参数错误。 |
memberRole |
V2NIMTeamMemberRole |
是 | 群成员角色类型。仅支持设置为群普通成员或群管理员,否则返回 191004 参数错误。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
String teamId = "123456";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
List<String> memberAccountIds = new ArrayList<>();
memberAccountIds.add("test1");
V2NIMTeamMemberRole memberRole = V2NIMTeamMemberRole.V2NIM_TEAM_MEMBER_ROLE_MANAGER;
v2TeamService.updateTeamMemberRole(teamId, teamType, memberAccountIds, memberRole, result -> {
// 更新群组成员角色成功
}, error -> {
// 更新群组成员角色失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] updateTeamMemberRole:@"teamId" teamType:V2NIM_TEAM_TYPE_NORMAL memberAccountIds:@[@"accountId"] memberRole:V2NIM_TEAM_MEMBER_ROLE_NORMAL success:^{
// 更新群组成员角色成功
} failure:^(V2NIMError * _Nonnull error) {
// 更新群组成员角色失败
}];
C++std::vector<std::string> memberAccountIds;
memberAccountIds.push_back("account1");
teamService.updateTeamMemberRole(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
memberAccountIds,
V2NIM_TEAM_MEMBER_ROLE_MANAGER,
[]() {
// update team member role success
},
[](V2NIMError error) {
// update team member role failed, handle error
}
);
TypeScriptawait nim.V2NIMTeamService.updateTeamMemberRole("123456", 1, ["accountId1"], 0)
TypeScriptawait v2.teamService.updateTeamMemberRole(teamId, teamType, memberAccountIds, memberRole)
TypeScripttry {
const teamId: string = "123456"
const teamType: V2NIMTeamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL
const memberAccountIds: string[] = ["aaa", "bbb"]
const memberRole: V2NIMTeamMemberRole = V2NIMTeamMemberRole.V2NIM_TEAM_MEMBER_ROLE_MANAGER
await nim.teamService.updateTeamMemberRole(teamId, teamType, memberAccountIds, memberRole)
// success
}
catch (err) {
// fail
}
返回参数
无返回值。
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。更新成功,返回onTeamMemberInfoUpdated
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
更新成功,返回 onTeamMemberInfoUpdated
回调。
更新成功,返回 teamMemberInfoUpdated
回调。
transferTeamOwner
接口描述
转让群主身份。
本地端或多端同步转让群主身份成功后:
- 群组内所有成员收到群组通知消息,通知消息类型为
V2NIMMessageNotificationType.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_OWNER_TRANSFER(6)
。以及群信息更新回调onTeamInfoUpdated
和群成员信息变更回调onTeamMemberInfoUpdated
。 - 若调用该方法时设置
leave
参数为true
,即转让群主身份后同时退出该群:- 操作方:退出群组,收到退出群组回调
onTeamLeft
。 - 群组内所有成员:
- 收到成员退出群组回调
onTeamMemberLeft
。 - 收到群组通知消息,通知消息类型为
V2NIMMessageNotificationType.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_LAVE(2)
。
- 收到成员退出群组回调
- 操作方:退出群组,收到退出群组回调
- 仅允许群主调用该接口,否则返回错误码 109427。
- 不允许转让给自己。
参数说明
Javavoid transferTeamOwner(String teamId, V2NIMTeamType teamType, String accountId, boolean leave, V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountId |
String | 是 | 新群主账号,如果为空、不合法、不存在,或与操作者账号相同,则返回 191004 参数错误。 |
leave |
boolean | 否 | 转让群主身份后,是否同时退出该群: |
success |
V2NIMSuccessCallback |
是 | 转让成功回调。 |
failure |
V2NIMFailureCallback |
是 | 转让失败回调,返回 错误码。 |
Objective-C- (void)transferTeamOwner:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
accountId:(NSString *)accountId
leave:(BOOL)leave
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString * | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountId |
NSString * | 是 | 新群主账号,如果为空、不合法、不存在,或与操作者账号相同,则返回 191004 参数错误。 |
leave |
BOOL | 否 | 转让群主身份后,是否同时退出该群: |
success |
V2NIMSuccessCallback |
是 | 转让成功回调。 |
failure |
V2NIMFailureCallback |
是 | 转让失败回调,返回 错误码。 |
C++virtual void transferTeamOwner(nstd::string teamId,
V2NIMTeamType teamType,
nstd::string accountId,
bool leave,
V2NIMSuccessCallback<void> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
nstd::string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountId |
nstd::string | 是 | 新群主账号,如果为空、不合法、不存在,或与操作者账号相同,则返回 191004 参数错误。 |
leave |
bool | 否 | 转让群主身份后,是否同时退出该群: |
success |
V2NIMSuccessCallback |
是 | 转让成功回调。 |
failure |
V2NIMFailureCallback |
是 | 转让失败回调,返回 错误码。 |
TypeScripttransferTeamOwner(teamId: string, teamType: V2NIMTeamType, accountId: string, leave?: boolean): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountId |
string | 是 | 新群主账号,如果为空、不合法、不存在,或与操作者账号相同,则返回 191004 参数错误。 |
leave |
boolean | 否 | 转让群主身份后,是否同时退出该群: |
TypeScripttransferTeamOwner(teamId, teamType, accountId, leave): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountId |
string | 是 | 新群主账号,如果为空、不合法、不存在,或与操作者账号相同,则返回 191004 参数错误。 |
leave |
boolean | 否 | 转让群主身份后,是否同时退出该群: |
TypeScripttransferTeamOwner(teamId: string, teamType: V2NIMTeamType, accountId: string, leave?: boolean): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountId |
string | 是 | 新群主账号,如果为空、不合法、不存在,或与操作者账号相同,则返回 191004 参数错误。 |
leave |
boolean | 否 | 转让群主身份后,是否同时退出该群: |
示例代码
JavaV2TeamService v2TeamService = NIMClient.getService(V2TeamService.class);
String teamId = "123456";
V2TeamType teamType = V2TeamType.NORMAL;
String account = "test";
boolean leave = false;
v2TeamService.transferTeamOwner(teamId, teamType, account, leave, result -> {
// 转移群组群主成功
}, error -> {
// 转移群组群主失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] transferTeamOwner:@"teamId" teamType:V2NIM_TEAM_TYPE_NORMAL accountId:@"accountId" leave:YES success:^{
// 转移群组群主成功
} failure:^(V2NIMError * _Nonnull error) {
// 转移群组群主失败
}];
C++teamService.transferTeamOwner(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
"accountId",
false,
[]() {
// transfer team owner success
},
[](V2NIMError error) {
// transfer team owner failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.transferTeamOwner("123456", 1, "accountId1", true)
TypeScriptawait v2.teamService.transferTeamOwner(teamId, teamType, accountId, leave)
TypeScripttry {
const teamId: string = "123456"
const teamType: V2NIMTeamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL
const newAccountId: string = "aaa"
const isLeave: boolean = true
await nim.teamService.transferTeamOwner(teamId, teamType, newAccountId, isLeave)
// success
} catch (error) {
// fail
}
返回参数
无返回值。
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。转让成功,返回群信息更新回调onTeamInfoUpdated
和群成员信息变更回调onTeamMemberInfoUpdated
。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
转让成功,返回群信息更新回调 onTeamInfoUpdated
和群成员信息变更回调 onTeamMemberInfoUpdated
。
转让成功,返回群信息更新回调 teamInfoUpdated
和群成员信息变更回调 teamMemberInfoUpdated
。
updateSelfTeamMemberInfo
接口描述
更新本人群成员信息。
本地端或多端同步更新本人群成员信息成功后,群组内所有成员收到群成员信息变更回调 onTeamMemberInfoUpdated
。
参数说明
Javavoid updateSelfTeamMemberInfo(String teamId, V2NIMTeamType teamType, V2NIMUpdateSelfMemberInfoParams memberInfoParams,V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
memberInfoParams |
V2NIMUpdateSelfMemberInfoParams |
是 | 本人群成员信息配置,包含群成员昵称及服务端扩展字段。 |
success |
V2NIMSuccessCallback |
是 | 更新成功回调。 |
failure |
V2NIMFailureCallback |
是 | 更新失败回调,返回 错误码。 |
Objective-C- (void)updateSelfTeamMemberInfo:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
memberInfoParams:(V2NIMUpdateSelfMemberInfoParams *)memberInfoParams
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString * | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
memberInfoParams |
V2NIMUpdateSelfMemberInfoParams |
是 | 本人群成员信息配置,包含群成员昵称及服务端扩展字段。 |
success |
V2NIMSuccessCallback |
是 | 更新成功回调。 |
failure |
V2NIMFailureCallback |
是 | 更新失败回调,返回 错误码。 |
C++virtual void updateSelfTeamMemberInfo(std::string teamId,
V2NIMTeamType teamType,
V2NIMUpdateSelfMemberInfoParams memberInfoParams,
V2NIMSuccessCallback<void> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
std::string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
memberInfoParams |
V2NIMUpdateSelfMemberInfoParams |
是 | 本人群成员信息配置,包含群成员昵称及服务端扩展字段。 |
success |
V2NIMSuccessCallback |
是 | 更新成功回调。 |
failure |
V2NIMFailureCallback |
是 | 更新失败回调,返回 错误码。 |
TypeScriptupdateSelfTeamMemberInfo(teamId: string, teamType: V2NIMTeamType, memberInfoParams: V2NIMUpdateSelfMemberInfoParams): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
memberInfoParams |
V2NIMUpdateSelfMemberInfoParams |
是 | 本人群成员信息配置,包含群成员昵称及服务端扩展字段。 |
TypeScriptupdateSelfTeamMemberInfo(teamId, teamType, memberInfoParams): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
memberInfoParams |
V2NIMUpdateSelfMemberInfoParams |
是 | 本人群成员信息配置,包含群成员昵称及服务端扩展字段。 |
TypeScriptupdateSelfTeamMemberInfo(teamId: string, teamType: V2NIMTeamType, memberInfoParams: V2NIMUpdateSelfMemberInfoParams): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
memberInfoParams |
V2NIMUpdateSelfMemberInfoParams |
是 | 本人群成员信息配置,包含群成员昵称及服务端扩展字段。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
String teamId = "123456";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
V2NIMUpdateSelfMemberInfoParams memberInfoParams = new V2NIMUpdateSelfMemberInfoParams();
memberInfoParams.setTeamNick("test nick");
memberInfoParams.setServerExtension("test");
v2TeamService.updateSelfTeamMemberInfo(teamId,teamType, memberInfoParams, result -> {
// 修改自己的群成员信息成功
}, error -> {
// 修改自己的群成员信息失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] updateSelfTeamMemberInfo:@"teamId" teamType:V2NIM_TEAM_TYPE_NORMAL memberInfoParams:infoParams success:^{
// 修改自己的群成员信息成功
} failure:^(V2NIMError * _Nonnull error) {
// 修改自己的群成员信息失败
}];
C++V2NIMUpdateSelfMemberInfoParams memberInfoParams;
memberInfoParams.teamNick = "new nick";
teamService.updateSelfTeamMemberInfo(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
memberInfoParams,
[]() {
// update self team member info success
},
[](V2NIMError error) {
// update self team member info failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.updateSelfTeamMemberInfo("123456", 1, {
"teamNick": "test nick"
})
TypeScriptawait v2.teamService.updateSelfTeamMemberInfo("123456", 1, {
"teamNick": "test nick"
})
TypeScripttry {
const teamId: string = "123456"
const teamType: V2NIMTeamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL
const memberInfoParams: V2NIMUpdateSelfMemberInfoParams = {
teamNick: "nick",
serverExtension: "ext"
}
await teamService.updateSelfTeamMemberInfo(teamId, teamType, memberInfoParams)
// success
} catch (err) {
// fail
}
返回参数
无返回值。
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。更新成功,返回onTeamMemberInfoUpdated
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
更新成功,返回 onTeamMemberInfoUpdated
回调。
更新成功,返回 teamMemberInfoUpdated
回调。
updateTeamMemberNick
接口描述
更新群成员昵称。
本地端或多端同步更新成功后,群组内所有成员会收到群成员信息变更回调 onTeamMemberInfoUpdated
。
仅允许群主和管理员调用该接口,否则返回错误码 109432。
参数说明
Javavoid updateTeamMemberNick(String teamId, V2NIMTeamType teamType, String accountId, String teamNick,V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountId |
String | 是 | 群成员账号,如果为空、不合法、不存在,则返回 191004 参数错误。 |
teamNick |
String | 是 | 群成员新昵称,可以设置为 "",但不可设置 null,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
是 | 更新成功回调。 |
failure |
V2NIMFailureCallback |
是 | 更新失败回调,返回 错误码。 |
Objective-C- (void)updateTeamMemberNick:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
accountId:(NSString *)accountId
teamNick:(NSString *)teamNick
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString * | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountId |
NSString * | 是 | 群成员账号,如果为空、不合法、不存在,则返回 191004 参数错误。 |
teamNick |
NSString * | 是 | 群成员新昵称,可以设置为 "",但不可设置 null,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
是 | 更新成功回调。 |
failure |
V2NIMFailureCallback |
是 | 更新失败回调,返回 错误码。 |
C++virtual void updateTeamMemberNick(nstd::string teamId,
V2NIMTeamType teamType,
nstd::string accountId,
nstd::string teamNick,
V2NIMSuccessCallback<void> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
nstd::string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountId |
nstd::string | 是 | 群成员账号,如果为空、不合法、不存在,则返回 191004 参数错误。 |
teamNick |
nstd::string | 是 | 群成员新昵称,可以设置为 "",但不可设置 null,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
是 | 更新成功回调。 |
failure |
V2NIMFailureCallback |
是 | 更新失败回调,返回 错误码。 |
TypeScriptupdateTeamMemberNick(teamId: string, teamType: V2NIMTeamType, accountId: string, nick: string): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountId |
string | 是 | 群成员账号,如果为空、不合法、不存在,则返回 191004 参数错误。 |
nick |
string | 是 | 群成员新昵称,可以设置为 "",但不可设置 null,否则返回 191004 参数错误。 |
TypeScriptupdateTeamMemberNick(teamId, teamType, accountId, teamNick): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountId |
string | 是 | 群成员账号,如果为空、不合法、不存在,则返回 191004 参数错误。 |
nick |
string | 是 | 群成员新昵称,可以设置为 "",但不可设置 null,否则返回 191004 参数错误。 |
TypeScriptupdateTeamMemberNick(teamId: string, teamType: V2NIMTeamType, accountId: string, nick: string): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountId |
string | 是 | 群成员账号,如果为空、不合法、不存在,则返回 191004 参数错误。 |
nick |
string | 是 | 群成员新昵称,可以设置为 "",但不可设置 null,否则返回 191004 参数错误。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
String teamId = "123456";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
String account = "test";
String teamNick = "test nick";
v2TeamService.updateTeamMemberNick(teamId, teamType, account, teamNick, result -> {
// 修改群成员昵称成功
}, error -> {
// 修改群成员昵称失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] updateTeamMemberNick:@"teamId" teamType:V2NIM_TEAM_TYPE_NORMAL accountId:@"accountId" teamNick:@"test" success:^{
// 修改群成员昵称成功
} failure:^(V2NIMError * _Nonnull error) {
// 修改群成员昵称失败
}];
C++teamService.updateTeamMemberNick(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
"accountId",
"new nick",
[]() {
// update team member nick success
},
[](V2NIMError error) {
// update team member nick failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.updateTeamMemberNick("123456", 1, "accountId1", "test nick")
TypeScriptawait v2.teamService.updateTeamMemberNick("123456", 1, "accountId1", "test nick")
TypeScripttry {
const teamId: string = "123456"
const teamType: V2NIMTeamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL
const account: string = "aaa"
const nick: string = "new nick"
await teamService.updateTeamMemberNick(teamId, teamType, account, nick)
// success
} catch (err) {
// fail
}
返回参数
无返回值。
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。更新成功,返回onTeamMemberInfoUpdated
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
更新成功,返回 onTeamMemberInfoUpdated
回调。
更新成功,返回 teamMemberInfoUpdated
回调。
updateTeamMemberNickEx
接口描述
更新群成员昵称。
本地端或多端同步更新成功后,群组内所有成员会收到群成员信息变更回调 onTeamMemberInfoUpdated
。
- 仅允许群主和管理员调用该接口,否则返回错误码 109432。
- 该接口较
updateTeamMemberNick
接口,支持在更新时设置antispamConfig
字段,配置是否通过反垃圾审核。
参数说明
Javavoid updateTeamMemberNickEx(String teamId, V2NIMTeamType teamType, V2NIMUpdateMemberNickParams nickParams, V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
nickParams |
V2NIMUpdateMemberNickParams |
是 | 群昵称更新配置参数。 |
success |
V2NIMSuccessCallback |
是 | 更新成功回调。 |
failure |
V2NIMFailureCallback |
是 | 更新失败回调,返回 错误码。 |
Objective-C- (void)updateTeamMemberNickEx:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
nickParams:(V2NIMUpdateMemberNickParams *)nickParams
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString * | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
nickParams |
V2NIMUpdateMemberNickParams |
是 | 群昵称更新配置参数。 |
success |
V2NIMSuccessCallback |
是 | 更新成功回调。 |
failure |
V2NIMFailureCallback |
是 | 更新失败回调,返回 错误码。 |
C++virtual void updateTeamMemberNickEx(const nstd::string& teamId,
V2NIMTeamType teamType,
const V2NIMUpdateMemberNickParams& nickParams,
const V2NIMSuccessCallback<void>& success,
const V2NIMFailureCallback& failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
nstd::string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
nickParams |
V2NIMUpdateMemberNickParams |
是 | 群昵称更新配置参数。 |
success |
V2NIMSuccessCallback |
是 | 更新成功回调。 |
failure |
V2NIMFailureCallback |
是 | 更新失败回调,返回 错误码。 |
TypeScriptupdateTeamMemberNickEx(teamId: string, teamType: V2NIMTeamType, nickParams: V2NIMUpdateMemberNickParams): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
nickParams |
V2NIMUpdateMemberNickParams |
是 | 群昵称更新配置参数。 |
TypeScriptupdateTeamMemberNickEx(teamId: string, teamType: V2NIMTeamType, nickParams: V2NIMUpdateMemberNickParams): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
nickParams |
V2NIMUpdateMemberNickParams |
是 | 群昵称更新配置参数。 |
TypeScriptupdateTeamMemberNickEx(teamId: string, teamType: V2NIMTeamType, nickParams: V2NIMUpdateMemberNickParams): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
nickParams |
V2NIMUpdateMemberNickParams |
是 | 群昵称更新配置参数。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
String teamId = "123456";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
V2NIMUpdateMemberNickParams nickParams = new V2NIMUpdateMemberNickParams();
nickParams.setAccountId("test");
nickParams.setTeamNick("test nick");
// 配置反垃圾审核参数(可选)
V2NIMAntispamConfig antispamConfig = new V2NIMAntispamConfig();
antispamConfig.setEnable(true);
nickParams.setAntispamConfig(antispamConfig);
v2TeamService.updateTeamMemberNickEx(teamId, teamType, nickParams, result -> {
// 修改群成员昵称成功
}, error -> {
// 修改群成员昵称失败
});
Objective-CV2NIMUpdateMemberNickParams *nickParams = [[V2NIMUpdateMemberNickParams alloc] init];
nickParams.accountId = @"accountId";
nickParams.teamNick = @"test nick";
// 配置反垃圾审核参数(可选)
V2NIMAntispamConfig *antispamConfig = [[V2NIMAntispamConfig alloc] init];
antispamConfig.enable = YES;
nickParams.antispamConfig = antispamConfig;
[[[NIMSDK sharedSDK] v2TeamService] updateTeamMemberNickEx:@"teamId"
teamType:V2NIM_TEAM_TYPE_NORMAL
nickParams:nickParams
success:^{
// 修改群成员昵称成功
} failure:^(V2NIMError * _Nonnull error) {
// 修改群成员昵称失败
}];
C++V2NIMUpdateMemberNickParams nickParams;
nickParams.accountId = "accountId";
nickParams.teamNick = "new nick";
// 配置反垃圾审核参数(可选)
V2NIMAntispamConfig antispamConfig;
antispamConfig.enable = true;
nickParams.antispamConfig = antispamConfig;
teamService.updateTeamMemberNickEx(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
nickParams,
[]() {
// update team member nick success
},
[](V2NIMError error) {
// update team member nick failed, handle error
});
TypeScripttry {
const nickParams = {
accountId: "accountId1",
teamNick: "test nick",
// 配置反垃圾审核参数(可选)
antispamConfig: {
enable: true
}
};
await nim.V2NIMTeamService.updateTeamMemberNickEx("123456", 1, nickParams);
// 修改群成员昵称成功
} catch (err) {
// 修改群成员昵称失败
console.error(err);
}
TypeScriptawait v2.teamService.updateTeamMemberNickEx(teamId, teamType, {
accountId: 'member1',
teamNick: 'newNick',
})
TypeScripttry {
const teamId: string = "123456";
const teamType: V2NIMTeamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
const nickParams: V2NIMUpdateMemberNickParams = {
accountId: "aaa",
teamNick: "new nick",
// 配置反垃圾审核参数(可选)
antispamConfig: {
enable: true
}
};
await teamService.updateTeamMemberNickEx(teamId, teamType, nickParams);
// 修改群成员昵称成功
} catch (err) {
// 修改群成员昵称失败
console.error(err);
}
返回参数
无返回值。
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。更新成功,返回onTeamMemberInfoUpdated
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
更新成功,返回 onTeamMemberInfoUpdated
回调。
更新成功,返回 teamMemberInfoUpdated
回调。
setTeamChatBannedMode
接口描述
设置群组禁言模式。
本地端或多端同步设置成功后,群组内所有成员会收到群组信息变更回调 onTeamInfoUpdate
以及群信息变更的通知类消息,消息类型为 V2NIMMessageNotificationType.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_UPDATE_TINFO(3)
。
仅允许群主和管理员调用该接口,否则返回错误码 109432。
参数说明
Javavoid setTeamChatBannedMode(String teamId, V2NIMTeamType teamType, V2NIMTeamChatBannedMode chatBannedMode,V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
chatBannedMode |
V2NIMTeamChatBannedMode |
是 | 群组禁言模式。 |
success |
V2NIMSuccessCallback |
是 | 设置成功回调。 |
failure |
V2NIMFailureCallback |
是 | 设置失败回调,返回 错误码。 |
Objective-C- (void)setTeamChatBannedMode:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
chatBannedMode:(V2NIMTeamChatBannedMode)chatBannedMode
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString * | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
chatBannedMode |
V2NIMTeamChatBannedMode |
是 | 群组禁言模式。 |
success |
V2NIMSuccessCallback |
是 | 设置成功回调。 |
failure |
V2NIMFailureCallback |
是 | 设置失败回调,返回 错误码。 |
C++virtual void setTeamChatBannedMode(std::string teamId,
V2NIMTeamType teamType,
V2NIMTeamChatBannedMode chatBannedMode,
V2NIMSuccessCallback<void> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
std::string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
chatBannedMode |
V2NIMTeamChatBannedMode |
是 | 群组禁言模式。 |
success |
V2NIMSuccessCallback |
是 | 设置成功回调。 |
failure |
V2NIMFailureCallback |
是 | 设置失败回调,返回 错误码。 |
TypeScriptsetTeamChatBannedMode(teamId: string, teamType: V2NIMTeamType, chatBannedMode: V2NIMTeamChatBannedMode): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
chatBannedMode |
V2NIMTeamChatBannedMode |
是 | 群组禁言模式。 |
TypeScriptsetTeamChatBannedMode(teamId, teamType, chatBannedMode): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
chatBannedMode |
V2NIMTeamChatBannedMode |
是 | 群组禁言模式。 |
TypeScriptsetTeamChatBannedMode(teamId: string, teamType: V2NIMTeamType, chatBannedMode: V2NIMTeamChatBannedMode): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
chatBannedMode |
V2NIMTeamChatBannedMode |
是 | 群组禁言模式。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
String teamId = "123456";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
V2NIMTeamChatBannedMode chatBannedMode = V2NIMTeamChatBannedMode.V2NIM_TEAM_CHAT_BANNED_MODE_BANNED_NORMAL;
v2TeamService.setTeamChatBannedMode(teamId,teamType, chatBannedMode, result -> {
// 设置群组禁言模式成功
}, error -> {
// 设置群组禁言模式失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] setTeamChatBannedMode:@"teamId" teamType:V2NIM_TEAM_TYPE_NORMAL chatBannedMode:V2NIM_TEAM_CHAT_BANNED_MODE_BANNED_NORMAL success:^{
// 设置群组禁言模式成功
} failure:^(V2NIMError * _Nonnull error) {
// 设置群组禁言模式失败
}];
C++teamService.setTeamChatBannedMode(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
V2NIM_TEAM_CHAT_BANNED_MODE_BANNED_NORMAL,
[]() {
// set team chat banned mode success
},
[](V2NIMError error) {
// set team chat banned mode failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.setTeamChatBannedMode("123456", 1, 1)
TypeScriptawait v2.teamService.setTeamChatBannedMode("123456", 1, 1)
TypeScripttry {
const teamId: string = "123456"
const teamType: V2NIMTeamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL
const chatBannedMode: V2NIMTeamChatBannedMode = V2NIMTeamChatBannedMode.V2NIM_TEAM_CHAT_BANNED_MODE_BANNED_NORMAL
await teamService.setTeamChatBannedMode(this.teamId, this.teamType, this.chatBannedMode)
// success
} catch (err) {
// fail
}
返回参数
无返回值。
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。设置成功,返回onTeamInfoUpdate
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
更新成功,返回 onTeamInfoUpdate
回调。
更新成功,返回 teamInfoUpdate
回调。
setTeamMemberChatBannedStatus
接口描述
设置群组成员禁言状态。
本地端或多端同步设置成功后,群组内所有成员会收到群成员信息变更回调 onTeamMemberInfoUpdated
以及群成员禁言的通知类消息,消息类型为 V2NIMMessageNotificationType.V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_BANNED_TEAM_MEMBER(10)
。
仅允许群主和管理员调用该接口,否则返回错误码 109432。
参数说明
Javavoid setTeamMemberChatBannedStatus(String teamId, V2NIMTeamType teamType, String accountId, boolean chatBanned,V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountId |
String | 是 | 群组成员账号,如果为空、不合法、不存在,则返回 191004 参数错误。 |
chatBanned |
boolean | 是 | 群组成员是否被禁言。 |
success |
V2NIMSuccessCallback |
是 | 设置成功回调。 |
failure |
V2NIMFailureCallback |
是 | 设置失败回调,返回 错误码。 |
Objective-C- (void)setTeamMemberChatBannedStatus:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
accountId:(NSString *)accountId
chatBanned:(BOOL)chatBanned
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString * | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountId |
NSString * | 是 | 群组成员账号,如果为空、不合法、不存在,则返回 191004 参数错误。 |
chatBanned |
BOOL | 是 | 群组成员是否被禁言。 |
success |
V2NIMSuccessCallback |
是 | 设置成功回调。 |
failure |
V2NIMFailureCallback |
是 | 设置失败回调,返回 错误码。 |
C++virtual void setTeamMemberChatBannedStatus(nstd::string teamId,
V2NIMTeamType teamType,
nstd::string accountId,
bool chatBanned,
V2NIMSuccessCallback<void> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
nstd::string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountId |
nstd::string | 是 | 群组成员账号,如果为空、不合法、不存在,则返回 191004 参数错误。 |
chatBanned |
bool | 是 | 群组成员是否被禁言。 |
success |
V2NIMSuccessCallback |
是 | 设置成功回调。 |
failure |
V2NIMFailureCallback |
是 | 设置失败回调,返回 错误码。 |
TypeScriptsetTeamMemberChatBannedStatus(teamId: string, teamType: V2NIMTeamType, accountId: string, chatBanned: boolean): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountId |
string | 是 | 群组成员账号,如果为空、不合法、不存在,则返回 191004 参数错误。 |
chatBanned |
boolean | 是 | 群组成员是否被禁言。 |
TypeScriptsetTeamMemberChatBannedStatus(teamId, teamType, accountId, chatBanned): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountId |
string | 是 | 群组成员账号,如果为空、不合法、不存在,则返回 191004 参数错误。 |
chatBanned |
boolean | 是 | 群组成员是否被禁言。 |
TypeScriptsetTeamMemberChatBannedStatus(teamId: string, teamType: V2NIMTeamType, accountId: string, chatBanned: boolean): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountId |
string | 是 | 群组成员账号,如果为空、不合法、不存在,则返回 191004 参数错误。 |
chatBanned |
boolean | 是 | 群组成员是否被禁言。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
String teamId = "123456";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
String accountId = "test";
boolean chatBanned = true;
v2TeamService.setTeamMemberChatBannedStatus(teamId,teamType, accountId, chatBanned, result -> {
// 设置群组成员聊天禁言状态成功
}, error -> {
// 设置群组成员聊天禁言状态失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] setTeamMemberChatBannedStatus:@"teamId" teamType:V2NIM_TEAM_TYPE_NORMAL accountId:@"accountId" chatBanned:YES success:^{
// 设置群组成员聊天禁言状态成功
} failure:^(V2NIMError * _Nonnull error) {
// 设置群组成员聊天禁言状态失败
}];
C++teamService.setTeamMemberChatBannedStatus(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
"accountId",
true,
[]() {
// set team member chat banned status success
},
[](V2NIMError error) {
// set team member chat banned status failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.setTeamMemberChatBannedStatus("123456", 1, "accountId1", true)
TypeScriptawait v2.teamService.setTeamMemberChatBannedStatus("123456", 1, "accountId1", true)
TypeScripttry {
const teamId: string = "123456"
const teamType: V2NIMTeamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL
const account: string = "aaaa"
const chatBanned: boolean = true
await teamService.setTeamMemberChatBannedStatus(teamId, teamType, accountId, chatBanned)
// success
} catch (err) {
// fail
}
返回参数
无返回值。
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。设置成功,返回onTeamMemberInfoUpdated
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
更新成功,返回 onTeamMemberInfoUpdated
回调。
更新成功,返回 teamMemberInfoUpdated
回调。
getJoinedTeamList
接口描述
按照群组类型获取已经加入的群组列表。返回群组列表按照创建时间的升序排序。
- 获取前请确保指定的群组存在。
- 群组数据同步(
V2NIMTeamListener.onSyncFinished
)完成前,可能获取不到完整数据。
参数说明
Javavoid getJoinedTeamList(List<V2NIMTeamType> teamTypes, V2NIMSuccessCallback<List<V2NIMTeam>> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamTypes |
List<V2NIMTeamType > |
否 | 群组类型列表。设置为 null 或空则表示获取所有类型的群组。 |
success |
V2NIMSuccessCallback |
是 | 获取成功回调,返回 V2NIMTeam 列表。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
Objective-C- (void)getJoinedTeamList:(NSArray<NSNumber *> *)teamTypes
success:(nullable V2NIMTeamInfoListCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamTypes |
NSArray<NSNumber *> * | 否 | 群组类型列表。设置为 null 或空则表示获取所有类型的群组。 |
success |
V2NIMTeamInfoListCallback |
是 | 获取成功回调,返回 V2NIMTeam 列表,可自定义设置。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
C++virtual void getJoinedTeamList(nstd::vector<V2NIMTeamType> teamTypes,
V2NIMSuccessCallback<nstd::vector<V2NIMTeam>> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamTypes |
nstd::vector<V2NIMTeamType > |
否 | 群组类型列表。设置为 null 或空则表示获取所有类型的群组。 |
success |
V2NIMSuccessCallback |
是 | 获取成功回调,返回 V2NIMTeam 列表。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
TypeScriptgetJoinedTeamList(teamTypes?: V2NIMTeamType[]): Promise<V2NIMTeam[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamTypes |
V2NIMTeamType [] |
否 | 群组类型列表。不可设置为 null,设置为空则表示获取所有类型的群组。 |
TypeScriptgetJoinedTeamList(teamTypes): Promise<V2NIMTeam[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamTypes |
V2NIMTeamType [] |
否 | 群组类型列表。不可设置为 null,设置为空则表示获取所有类型的群组。 |
TypeScriptgetJoinedTeamList(teamTypes?: V2NIMTeamType[]): Promise<V2NIMTeam[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamTypes |
V2NIMTeamType [] |
否 | 群组类型列表。不可设置为 null,设置为空则表示获取所有类型的群组。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
List<V2NIMTeamType> teamTypes = new ArrayList<>();
teamTypes.add(V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL);
teamTypes.add(V2NIMTeamType.V2NIM_TEAM_TYPE_SUPER);
v2TeamService.getJoinedTeamList(teamTypes, result -> {
// 获取当前已经加入的群组列表成功
}, error -> {
// 获取当前已经加入的群组列表失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] getJoinedTeamList:nil success:^(NSArray<V2NIMTeam *> * _Nonnull teamList) {
// 获取当前已经加入的群组列表成功
} failure:^(V2NIMError * _Nonnull error) {
// 获取当前已经加入的群组列表失败
}];
C++nstd::vector<V2NIMTeamType> teamTypes;
teamTypes.push_back(V2NIM_TEAM_TYPE_NORMAL);
teamService.getJoinedTeamList(
teamTypes,
[](nstd::vector<V2NIMTeam> teamList) {
// get joined team list success
},
[](V2NIMError error) {
// get joined team list failed, handle error
}
);
TypeScriptawait nim.V2NIMTeamService.getJoinedTeamList([1])
TypeScriptconst teams = await v2.teamService.getJoinedTeamList([1])
TypeScripttry {
const teamTypes: V2NIMTeamType[] = [V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL, V2NIMTeamType.V2NIM_TEAM_TYPE_SUPER]
const teams: V2NIMTeam[] = await nim.teamService.getJoinedTeamList(this.teamType)
// success
} catch (e) {
// fail
}
返回参数
无返回值。
Promise<V2NIMTeam
[]> 群组列表
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调,包含V2NIMTeam
列表。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
- 请求成功,返回
V2NIMTeamInfoListCallback
回调,可自定义设置。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
getJoinedTeamCount
接口描述
按照群组类型获取已经加入的群组数量。
- 该方法为同步。
- 群组数据同步(
V2NIMTeamListener.onSyncFinished
)完成前,可能获取不到完整数据。
参数说明
Javaint getJoinedTeamCount(List<V2NIMTeamType> teamTypes);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamTypes |
List<V2NIMTeamType > |
否 | 群组类型列表。设置为 null 或空则表示获取所有类型的群组数量。 |
Objective-C- (NSInteger)getJoinedTeamCount:(NSArray<NSNumber *> *)teamTypes;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamTypes |
NSArray<NSNumber *> * | 否 | 群组类型列表。设置为 null 或空则表示获取所有类型的群组数量。 |
C++virtual uint32_t getJoinedTeamCount(nstd::vector<V2NIMTeamType> teamTypes) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamTypes |
nstd::vector<V2NIMTeamType > |
否 | 群组类型列表。设置为 null 或空则表示获取所有类型的群组数量。 |
TypeScriptgetJoinedTeamCount(teamTypes?: V2NIMTeamType[]): number
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamTypes |
V2NIMTeamType [] |
否 | 群组类型列表。不可设置为 null,设置为空则表示获取所有类型的群组数量。 |
TypeScriptgetJoinedTeamCount(teamTypes): number
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamTypes |
V2NIMTeamType [] |
否 | 群组类型列表。不可设置为 null,设置为空则表示获取所有类型的群组数量。 |
TypeScriptgetJoinedTeamCount(teamTypes?: V2NIMTeamType[]): Promise<number>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamTypes |
V2NIMTeamType [] |
否 | 群组类型列表。不可设置为 null,设置为空则表示获取所有类型的群组数量。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
List<V2NIMTeamType> teamTypes = new ArrayList<>();
teamTypes.add(V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL);
teamTypes.add(V2NIMTeamType.V2NIM_TEAM_TYPE_SUPER);
int joinedTeamCount = v2TeamService.getJoinedTeamCount(teamTypes);
Objective-CNSInteger allJoinedTeamCount = [[[NIMSDK sharedSDK] v2TeamService] getJoinedTeamCount:nil];
C++nstd::vector<V2NIMTeamType> teamTypes;
teamTypes.push_back(V2NIM_TEAM_TYPE_NORMAL);
auto count = teamService.getJoinedTeamCount(teamTypes);
TypeScriptnim.V2NIMTeamService.getJoinedTeamCount([1])
TypeScriptconst count = v2.teamService.getJoinedTeamCount([1])
TypeScripttry {
const teamTypes: V2NIMTeamType[] = [V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL, V2NIMTeamType.V2NIM_TEAM_TYPE_SUPER]
const count: number = await nim.teamService.getJoinedTeamCount(this.teamType)
// success
} catch (e) {
// fail
}
返回参数
群组数量。
相关回调
无。
getTeamMemberList
接口描述
分页获取群组成员列表。返回成员列表按照加入群组的时间戳(V2NIMTeamMember.joinTime
)排序。
- 获取前请确保指定的群组存在。
- 群组数据同步(
V2NIMTeamListener.onSyncFinished
)完成前,可能获取不到完整数据。
参数说明
Javavoid getTeamMemberList(String teamId, V2NIMTeamType teamType, V2NIMTeamMemberQueryOption queryOption, V2NIMSuccessCallback<V2NIMTeamMemberListResult> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
queryOption |
V2NIMTeamMemberQueryOption |
是 | 群组成员分页查询选项。 |
success |
V2NIMSuccessCallback |
是 | 获取成功回调,返回 V2NIMTeamMemberListResult 。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
Objective-C- (void)getTeamMemberList:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
queryOption:(V2NIMTeamMemberQueryOption *)queryOption
success:(nullable V2NIMTeamMemberListResultCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString * | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
queryOption |
V2NIMTeamMemberQueryOption * |
是 | 群组成员分页查询选项。 |
success |
V2NIMTeamMemberListResultCallback |
是 | 获取成功回调,可自定义设置。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
C++virtual void getTeamMemberList(std::string teamId,
V2NIMTeamType teamType,
V2NIMTeamMemberQueryOption queryOption,
V2NIMSuccessCallback<V2NIMTeamMemberListResult> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
std::string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
queryOption |
V2NIMTeamMemberQueryOption |
是 | 群组成员分页查询选项。 |
success |
V2NIMSuccessCallback |
是 | 获取成功回调,返回 V2NIMTeamMemberListResult 。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
TypeScriptgetTeamMemberList(teamId: string, teamType: V2NIMTeamType, queryOption: V2NIMTeamMemberQueryOption): Promise<V2NIMTeamMemberListResult>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
queryOption |
V2NIMTeamMemberQueryOption |
是 | 群组成员分页查询选项。 |
TypeScriptgetTeamMemberList(teamId: string, teamType: V2NIMTeamType, queryOption: V2NIMTeamMemberQueryOption): Promise<V2NIMTeamMemberListResult>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
queryOption |
V2NIMTeamMemberQueryOption |
是 | 群组成员分页查询选项。 |
TypeScriptgetTeamMemberList(teamId: string, teamType: V2NIMTeamType, queryOption: V2NIMTeamMemberQueryOption): Promise<V2NIMTeamMemberListResult>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
queryOption |
V2NIMTeamMemberQueryOption |
是 | 群组成员分页查询选项。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
String teamId = "123456";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
V2NIMTeamMemberQueryOption queryOption = new V2NIMTeamMemberQueryOption();
queryOption.setRoleQueryType(V2NIMTeamMemberRoleQueryType.V2NIM_TEAM_MEMBER_ROLE_QUERY_TYPE_ALL);
// 设置分页偏移,首次传"",后续拉取采用上一次返回的 nextToken
queryOption.setNextToken("");
queryOption.setDirection(V2NIMQueryDirection.V2NIM_QUERY_DIRECTION_DESC);
queryOption.setLimit(100);
queryOption.setOnlyChatBanned(false);
v2TeamService.getTeamMemberList(teamId, teamType, queryOption, result -> {
// 获取群组成员列表成功
}, error -> {
// 获取群组成员列表失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] getTeamMemberList:@"teamId" teamType:V2NIM_TEAM_TYPE_NORMAL queryOption:queryOption success:^(V2NIMTeamMemberListResult * _Nonnull result) {
// 获取群组成员列表成功
} failure:^(V2NIMError * _Nonnull error) {
// 获取群组成员列表失败
}];
C++V2NIMTeamMemberQueryOption queryOption;
queryOption.nextToken = ""; // first page
queryOption.limit = 10;
queryOption.direction = V2NIM_QUERY_DIRECTION_DESC;
teamService.getTeamMemberList(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
queryOption,
[](V2NIMTeamMemberListResult result) {
// get team members success
},
[](V2NIMError error) {
// get team members failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.getTeamMemberList(
"123456",
1,
{
"roleQueryType": 0,
"onlyChatBanned": false,
"direction": 0,
"limit": 100,
"nextToken": ""
}
)
TypeScriptconst result = await v2.teamService.getTeamMemberList(teamId, teamType, {
"roleQueryType": 0,
"onlyChatBanned": false,
"direction": 0,
"limit": 100,
"nextToken": ""
}
)
TypeScripttry {
const teamId: string = "123456"
const teamType: V2NIMTeamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL
const queryOption: V2NIMTeamMemberQueryOption = {
roleQueryType: V2NIMTeamMemberRoleQueryType.V2NIM_TEAM_MEMBER_ROLE_QUERY_TYPE_NORMAL,
onlyChatBanned: false,
direction: V2NIMQueryDirection.V2NIM_QUERY_DIRECTION_DESC
limit: 50
nextToken: undefined
}
const memberListResult: V2NIMTeamMemberListResult = await nim.teamService.getTeamMemberList(teamId, teamType, queryOption)
// success
} catch (err) {
// fail
}
返回参数
无返回值。
Promise<V2NIMTeamMemberListResult
> 群组成员查询结果
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调,包含V2NIMTeamMemberListResult
。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
- 请求成功,返回
V2NIMTeamMemberListResultCallback
回调,可自定义设置。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
getTeamMemberListByIds
接口描述
根据群成员账号批量获取群组成员列表。返回成员列表按照加入群组的时间戳(V2NIMTeamMember.joinTime
)排序。
SDK 获取策略如下:

群组数据同步(V2NIMTeamListener.onSyncFinished
)完成前,可能获取不到完整数据。
参数说明
Javavoid getTeamMemberListByIds(String teamId, V2NIMTeamType teamType, List<String> accountIds, V2NIMSuccessCallback<List<V2NIMTeamMember>> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID 列表,不可为空,否则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountIds |
List<String> | 是 | 群成员账号列表,不可为 null 或空,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
是 | 获取成功回调,返回 V2NIMTeamMember 列表。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
Objective-C- (void)getTeamMemberListByIds:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
accountIds:(NSArray<NSString *> *)accountIds
success:(nullable V2NIMTeamMemberListCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString * | 是 | 群组 ID 列表,不可为空,否则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountIds |
NSArray<NSString *> * | 是 | 群成员账号列表,不可为 null 或空,否则返回 191004 参数错误。 |
success |
V2NIMTeamMemberListCallback |
是 | 获取成功回调,返回 V2NIMTeamMember 列表,可自定义设置。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
C++virtual void getTeamMemberListByIds(nstd::string teamId,
V2NIMTeamType teamType,
nstd::vector<nstd::string> accountIds,
V2NIMSuccessCallback<nstd::vector<V2NIMTeamMember>> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
nstd::string | 是 | 群组 ID 列表,不可为空,否则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountIds |
nstd::vector<nstd::string> | 是 | 群成员账号列表,不可为 null 或空,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
是 | 获取成功回调,返回 V2NIMTeamMember 列表。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
TypeScriptgetTeamMemberListByIds(teamId: string, teamType: V2NIMTeamType, accountIds: string[]): Promise<V2NIMTeamMember[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID 列表,不可为空,否则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountIds |
string[] | 是 | 群成员账号列表,不可为 null 或空,否则返回 191004 参数错误。 |
TypeScriptgetTeamMemberListByIds(teamId, teamType, accountIds): Promise<V2NIMTeamMember[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID 列表,不可为空,否则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountIds |
string[] | 是 | 群成员账号列表,不可为 null 或空,否则返回 191004 参数错误。 |
TypeScriptgetTeamMemberListByIds(teamId: string, teamType: V2NIMTeamType, accountIds: string[]): Promise<V2NIMTeamMember[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID 列表,不可为空,否则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountIds |
string[] | 是 | 群成员账号列表,不可为 null 或空,否则返回 191004 参数错误。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
String teamId = "123456";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
List<String> accountIds = new ArrayList<>();
accountIds.add("test1");
accountIds.add("test2");
v2TeamService.getTeamMemberListByIds(teamId,teamType, accountIds, result -> {
// 获取群组成员列表成功
}, error -> {
// 获取群组成员列表失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] getTeamMemberListByIds:@"teamId" teamType:V2NIM_TEAM_TYPE_NORMAL accountIds:@[@"accountId"] success:^(NSArray<V2NIMTeamMember *> * _Nonnull memberList) {
// 获取群组成员列表成功
} failure:^(V2NIMError * _Nonnull error) {
// 获取群组成员列表失败
}];
C++nstd::vector<nstd::string> accountIds;
accountIds.push_back("account1");
accountIds.push_back("account2");
teamService.getTeamMemberListByIds(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
accountIds,
[](nstd::vector<V2NIMTeamMember> memberList) {
// get team members by account ids success
},
[](V2NIMError error) {
// get team members by account ids failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.getTeamMemberListByIds("123456", 1, ["accountId1"])
TypeScriptconst members = await v2.teamService.getTeamMemberListByIds(teamId, teamType, accountIds)
TypeScripttry {
const teamId: string = "123456"
const teamType: V2NIMTeamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL
const accounts = ["aaa", "bbb"]
const members: V2NIMTeamMember[] = await nim.teamService.getTeamMemberListByIds(teamId, teamType, accountIds)
// success
} catch (err) {
// fail
}
返回参数
无返回值。
Promise<V2NIMTeamMember
[]> 群成员列表
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调,包含V2NIMTeamMember
列表。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
- 请求成功,返回
V2NIMTeamMemberListCallback
回调,可自定义设置。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
getTeamMemberInvitor
接口描述
根据群成员账号获取群成员邀请人。
SDK 获取策略如下:

群组数据同步(V2NIMTeamListener.onSyncFinished
)完成前,可能获取不到完整数据。
参数说明
Javavoid getTeamMemberInvitor(String teamId, V2NIMTeamType teamType, List<String> accountIds, V2NIMSuccessCallback<Map<String, String>> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID 列表,不可为空,否则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountIds |
List |
是 | 群成员账号列表,不可为 null 或空,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
是 | 获取成功回调,返回格式如下: Map<String, String>(key: accountId, value: invitorAccountId) |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
Objective-C- (void)getTeamMemberInvitor:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
accountIds:(NSArray<NSString *> *)accountIds
success:(nullable V2NIMTeamMemberInvitorResultCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString * | 是 | 群组 ID 列表,不可为空,否则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountIds |
NSArray<NSString *> * | 是 | 群成员账号列表,不可为 null 或空,否则返回 191004 参数错误。 |
success |
V2NIMTeamMemberInvitorResultCallback |
是 | 获取成功回调,可自定义设置。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
C++virtual void getTeamMemberInvitor(nstd::string teamId,
V2NIMTeamType teamType,
nstd::vector<nstd::string> accountIds,
V2NIMSuccessCallback<nstd::map<nstd::string, nstd::string>> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
nstd::string | 是 | 群组 ID 列表,不可为空,否则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountIds |
nstd::vector<nstd::string> | 是 | 群成员账号列表,不可为 null 或空,否则返回 191004 参数错误。 |
success |
V2NIMSuccessCallback |
是 | 获取成功回调,返回格式如下: nstd::map<nstd::string, nstd::string>(key: accountId, value: invitorAccountId) |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
TypeScriptgetTeamMemberInvitor(teamId: string, teamType: V2NIMTeamType, accountIds: string[]): Promise<{ [accountId: string]: string }>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID 列表,不可为空,否则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountIds |
string[] | 是 | 群成员账号列表,不可为 null 或空,否则返回 191004 参数错误。 |
TypeScriptgetTeamMemberInvitor(teamId, teamType, accountIds): Promise<Map<string, string>>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID 列表,不可为空,否则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountIds |
string[] | 是 | 群成员账号列表,不可为 null 或空,否则返回 191004 参数错误。 |
TypeScriptgetTeamMemberInvitor(teamId: string, teamType: V2NIMTeamType, accountIds: string[]): Promise<{ [accountId: string]: string }>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID 列表,不可为空,否则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | 群组类型,包括高级群和超大群。 |
accountIds |
string[] | 是 | 群成员账号列表,不可为 null 或空,否则返回 191004 参数错误。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
String teamId = "123456";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
List<String> accountIds = new ArrayList<>();
accountIds.add("test1");
accountIds.add("test2");
v2TeamService.getTeamMemberInvitor(teamId,teamType, accountIds, result -> {
// 获取群组成员邀请人成功
}, error -> {
// 获取群组成员邀请人失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] getTeamMemberInvitor:@"teamId" teamType:V2NIM_TEAM_TYPE_NORMAL accountIds:@[@"accountId"] success:^(NSDictionary<NSString *,NSString *> * _Nonnull result) {
// 获取群组成员邀请人成功
} failure:^(V2NIMError * _Nonnull error) {
// 获取群组成员邀请人失败
}];
C++nstd::vector<nstd::string> accountIds;
accountIds.push_back("account1");
accountIds.push_back("account2");
teamService.getTeamMemberInvitor(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
accountIds,
[](nstd::map<nstd::string, nstd::string> invitors) {
// get team member invitor success
},
[](V2NIMError error) {
// get team member invitor failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.getTeamMemberInvitor("123456", 1, ["accountId1"])
TypeScriptconst invitorMap = await v2.teamService.getTeamMemberInvitor(teamId, teamType, accountIds)
TypeScripttry {
const teamId: string = "123456"
const teamType: V2NIMTeamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL
const accounts = ["aaa", "bbb"]
const keyValue = await nim.teamService.getTeamMemberInvitor(teamId, teamType, accountIds)
// success
} catch (err) {
// fail
}
返回参数
无返回值。
Promise<{ [accountId: string]: string }>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
- 请求成功,返回
V2NIMTeamMemberInvitorResultCallback
回调,可自定义设置。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
getTeamJoinActionInfoList
接口描述
分页获取入群操作相关信息列表。返回列表按照入群请求时间戳(V2NIMTeamJoinActionInfo.timestamp
)逆序排序。
仅查询本地数据。
参数说明
Javavoid getTeamJoinActionInfoList(V2NIMTeamJoinActionInfoQueryOption option, V2NIMSuccessCallback<V2NIMTeamJoinActionInfoResult> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
option |
V2NIMTeamJoinActionInfoQueryOption |
是 | 入群操作信息查询选项。 |
success |
V2NIMSuccessCallback |
是 | 获取成功回调,返回 V2NIMTeamJoinActionInfoResult 。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
Objective-C- (void)getTeamJoinActionInfoList:(V2NIMTeamJoinActionInfoQueryOption *)option
success:(nullable V2NIMTeamJoinActionInfoResultCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
option |
V2NIMTeamJoinActionInfoQueryOption * |
是 | 入群操作信息查询选项。 |
success |
V2NIMTeamJoinActionInfoResultCallback |
是 | 获取成功回调,可自定义设置。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
C++virtual void getTeamJoinActionInfoList(V2NIMTeamJoinActionInfoQueryOption option,
V2NIMSuccessCallback<V2NIMTeamJoinActionInfoResult> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
option |
V2NIMTeamJoinActionInfoQueryOption |
是 | 入群操作信息查询选项。 |
success |
V2NIMSuccessCallback |
是 | 获取成功回调,返回 V2NIMTeamJoinActionInfoResult 。 |
failure |
V2NIMFailureCallback |
是 | 获取失败回调,返回 错误码。 |
TypeScriptgetTeamJoinActionInfoList(option: V2NIMTeamJoinActionInfoQueryOption): Promise<V2NIMTeamJoinActionInfoResult>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
option |
V2NIMTeamJoinActionInfoQueryOption |
是 | 入群操作信息查询选项。 |
TypeScriptgetTeamJoinActionInfoList(option): Promise<V2NIMTeamJoinActionInfoResult>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
option |
V2NIMTeamJoinActionInfoQueryOption |
是 | 入群操作信息查询选项。 |
TypeScriptgetTeamJoinActionInfoList(option: V2NIMTeamJoinActionInfoQueryOption): Promise<V2NIMTeamJoinActionInfoResult>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
option |
V2NIMTeamJoinActionInfoQueryOption |
是 | 入群操作信息查询选项。 |
示例代码
JavaV2NIMTeamService v2TeamService = NIMClient.getService(V2NIMTeamService.class);
V2NIMTeamJoinActionInfoQueryOption option = new V2NIMTeamJoinActionInfoQueryOption();
option.setOffset(0L);
option.setLimit(50);
List<V2NIMTeamJoinActionType> types = new ArrayList<>();
types.add(V2NIMTeamJoinActionType.V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION);
types.add(V2NIMTeamJoinActionType.V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION);
option.setTypes(types);
List<V2NIMTeamJoinActionStatus> status = new ArrayList<>();
status.add(V2NIMTeamJoinActionStatus.V2NIM_TEAM_JOIN_ACTION_STATUS_INIT);
option.setStatus(status);
v2TeamService.getTeamJoinActionInfoList(option, result -> {
// 获取群加入相关信息成功
}, error -> {
// 获取群加入相关信息失败
});
Objective-C[[[NIMSDK sharedSDK] v2TeamService] getTeamJoinActionInfoList:queryParam success:^(V2NIMTeamJoinActionInfoResult * _Nonnull result) {
// 获取群加入相关信息成功
} failure:^(V2NIMError * _Nonnull error) {
// 获取群加入相关信息失败
}];
C++V2NIMTeamJoinActionInfoQueryOption option;
option.offset = 0;
option.limit = 10;
teamService.getTeamJoinActionInfoList(
option,
[](V2NIMTeamJoinActionInfoResult result) {
// get team join action info list success
},
[](V2NIMError error) {
// get team join action info list failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.getTeamJoinActionInfoList(
{
"offset": 0,
"limit": 50
}
)
TypeScriptconst result = await v2.teamService.getTeamJoinActionInfoList(
{
"offset": 0,
"limit": 50
}
)
TypeScripttry {
const params = {
types: [V2NIMTeamJoinActionType.V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION],
status: [V2NIMTeamJoinActionStatus.V2NIM_TEAM_JOIN_ACTION_STATUS_INIT],
offset: 0,
limit: 50
} as V2NIMTeamJoinActionInfoQueryOption
const actionList: V2NIMTeamJoinActionInfoResult = await nim.teamService.getTeamJoinActionInfoList(params)
// success
} catch (error) {
// fail
}
返回参数
无返回值。
Promise<V2NIMTeamJoinActionInfoResult
>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调,包含V2NIMTeamJoinActionInfoResult
。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
- 请求成功,返回
V2NIMTeamJoinActionInfoResultCallback
回调,可自定义设置。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
searchTeamByKeyword
接口描述
根据关键字搜索群信息(包括高级群和超大群)。
- 仅匹配群组名称。
- 不检验群组的有效性、是否加入。
仅查询本地数据。
参数说明
Java/**
* 根据关键字搜索群信息
* 混合搜索高级群和超大群,like 匹配
* 只搜索群名称
* 不限制群有效性,不限制是否加入,不限制群是否有效
* 基于本地数据存储查找
* @param keyword 关键字
* @param success
* @param failure
*/
void searchTeamByKeyword(String keyword, V2NIMSuccessCallback<List<V2NIMTeam>> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
keyword |
String | 是 | 搜索关键词。 |
success |
V2NIMSuccessCallback |
是 | 搜索成功回调,返回 V2NIMTeam 列表。 |
failure |
V2NIMFailureCallback |
是 | 搜索失败回调,返回 错误码。 |
Objective-C/**
* 根据关键字搜索群信息
*
* @param keyword 关键字
* @param success 成功回调
* @param failure 失败回调
*/
- (void)searchTeamByKeyword:(NSString *)keyword
success:(nullable V2NIMTeamInfoListCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
keyword |
NSString | 是 | 搜索关键词。 |
success |
V2NIMTeamInfoListCallback |
是 | 搜索成功回调,可自定义设置。 |
failure |
V2NIMFailureCallback |
是 | 搜索失败回调,返回 错误码。 |
C++virtual void v2::V2NIMTeamService::searchTeamByKeyword (" nstd::string keyword,
V2NIMSuccessCallback< nstd::vector< V2NIMTeam > > success,
V2NIMFailureCallback failure
)
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
keyword |
String | 是 | 搜索关键词。 |
success |
V2NIMSuccessCallback |
是 | 搜索成功回调,返回 V2NIMTeam 列表。 |
failure |
V2NIMFailureCallback |
是 | 搜索失败回调,返回 错误码。 |
TypeScript/**
* 根据关键字搜索群信息
* - 混合搜索高级群和超大群,like 匹配
* - 只搜索群名称
*/
searchTeamByKeyword(keyword: string): Promise<V2NIMTeam[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
keyword |
string | 是 | 搜索关键词。 |
TypeScript/**
* 根据关键字搜索群信息
* - 混合搜索高级群和超大群,like 匹配
* - 只搜索群名称
*/
searchTeamByKeyword(keyword): Promise<V2NIMTeam[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
keyword |
string | 是 | 搜索关键词。 |
TypeScriptsearchTeamByKeyword(keyword: string): Promise<V2NIMTeam[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
keyword |
string | 是 | 搜索关键词。 |
示例代码
JavaString keyword = "搜索关键字" ;
NIMClient.getService(V2NIMTeamService.class).searchTeamByKeyword(keyword,
new V2NIMSuccessCallback<List<V2NIMTeam>>() {
@Override
public void onSuccess(List<V2NIMTeam> v2NIMTeams) {
}
},
new V2NIMFailureCallback() {
@Override
public void onFailure(V2NIMError error) {
}
});
Objective-C- (void)searchTeam
{
[NIMSDK.sharedSDK.v2TeamService searchTeamByKeyword:@"keyword" success:^(NSArray<V2NIMTeam *> * _Nonnull teamList) {
// result
} failure:^(V2NIMError * _Nonnull error) {
// error
}];
}
C++teamService.searchTeamByKeyword(
"keyword",
[](nstd::vector<V2NIMTeam> teamList) {
// search team by keyword success
},
[](V2NIMError error) {
// search team by keyword failed, handle error
});
TypeScriptconst teams = await nim.V2NIMTeamService.searchTeamByKeyword('keyword')
TypeScriptconst teams = await v2.teamService.searchTeamByKeyword(keyword)
TypeScriptconst teams = await nim.teamService.searchTeamByKeyword('keyword')
返回参数
无返回值。
Promise<V2NIMTeam[]>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调,包含V2NIMTeam
列表。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
- 请求成功,返回
V2NIMTeamInfoListCallback
回调,可自定义设置。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
searchTeamMembers
接口描述
根据关键字搜索群成员(包括高级群和超大群)。
- 仅查询本地数据。
- Web 端不支持该接口。
参数说明
Java/**
* 根据关键字搜索群成员
* @param searchOption 搜索参数
* @param success
* @param failure
*/
void searchTeamMembers(V2NIMTeamMemberSearchOption searchOption, V2NIMSuccessCallback<V2NIMTeamMemberSearchResult> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
searchOption |
V2NIMTeamMemberSearchOption |
是 | 搜索配置项。 |
success |
V2NIMSuccessCallback |
是 | 搜索成功回调,返回 V2NIMTeamMemberSearchResult 。 |
failure |
V2NIMFailureCallback |
是 | 搜索失败回调,返回 错误码。 |
Objective-C/// 成功接收搜索群成员结果回调
typedef void (^V2NIMTeamMemberSearchResultCallback)(V2NIMTeamMemberSearchResult *result);
/**
* 根据关键字搜索群成员
*
* @param searchOption 搜索参数
* @param success 成功回调
* @param failure 失败回调
*/
- (void)searchTeamMembers:(V2NIMTeamMemberSearchOption *)searchOption
success:(nullable V2NIMTeamMemberSearchResultCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
searchOption |
V2NIMTeamMemberSearchOption |
是 | 搜索配置项。 |
success |
V2NIMTeamMemberSearchResultCallback |
是 | 搜索成功回调,可自定义设置。 |
failure |
V2NIMFailureCallback |
是 | 搜索失败回调,返回 错误码。 |
C++virtual void v2::V2NIMTeamService::searchTeamMembers ( V2NIMTeamMemberSearchOption option,
V2NIMSuccessCallback< V2NIMTeamMemberListResult > success,
V2NIMFailureCallback failure
)
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
searchOption |
V2NIMTeamMemberSearchOption |
是 | 搜索配置项。 |
success |
V2NIMSuccessCallback |
是 | 搜索成功回调,返回 V2NIMTeamMemberSearchResult 。 |
failure |
V2NIMFailureCallback |
是 | 搜索失败回调,返回 错误码。 |
TypescriptsearchTeamMembers(option): Promise<V2NIMTeamMemberListResult>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
searchOption |
V2NIMTeamMemberSearchOption |
是 | 搜索配置项。 |
TypescriptsearchTeamMembers(searchOption: V2NIMTeamMemberSearchOption): Promise<V2NIMTeamMemberSearchResult>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
searchOption |
V2NIMTeamMemberSearchOption |
是 | 搜索配置项。 |
示例代码
JavaV2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
String nextToken = "";
V2NIMTeamMemberSearchOption searchOption = V2NIMTeamMemberSearchOption.V2NIMTeamMemberSearchOptionBuilder.builder(keyword, teamType, nextToken)
// 按需配置
// .withLimit()
// .withOrder()
// .withTeamId()
.build();
NIMClient.getService(V2NIMTeamService.class).searchTeamMembers(searchOption, new V2NIMSuccessCallback<V2NIMTeamMemberSearchResult>() {
@Override
public void onSuccess(V2NIMTeamMemberSearchResult v2NIMTeamMemberSearchResult) {
}
}, new V2NIMFailureCallback() {
@Override
public void onFailure(V2NIMError error) {
}
});
Objective-C- (void)searchMember
{
V2NIMTeamMemberSearchOption *option = [[V2NIMTeamMemberSearchOption alloc] init];
option.keyword = @"keyword"; // keyword
option.teamType = V2NIM_TEAM_TYPE_NORMAL; // search all normal team
option.teamType = V2NIM_TEAM_TYPE_SUPER; // search all super team
option.teamId = @"123456"; // search specific team
option.limit = 20; // limit
option.order = V2NIM_SORT_ORDER_DESC;
option.nextToken = V2NIMTeamMemberSearchOption.initNextToken; // init
[NIMSDK.sharedSDK.v2TeamService searchTeamMembers:option success:^(V2NIMTeamMemberSearchResult * _Nonnull result) {
// result
result.memberList;
if (result.finished) {
// end
} else {
V2NIMTeamMemberSearchOption *nextOption = [option copy];
// move next
nextOption.nextToken = result.nextToken;
// again
[NIMSDK.sharedSDK.v2TeamService searchTeamMembers:nextOption success:^(V2NIMTeamMemberSearchResult * _Nonnull result) {
} failure:^(V2NIMError * _Nonnull error) {
}];
}
} failure:^(V2NIMError * _Nonnull error) {
// error
}];
}
C++V2NIMTeamMemberSearchOption option;
option.keyword = "keyword";
option.teamType = V2NIM_TEAM_TYPE_NORMAL;
option.pageToken = "";
teamService.searchTeamMembers(
option,
[](nstd::vector<V2NIMTeamMember> teamMembers) {
// search team members success
},
[](V2NIMError error) {
// search team members failed, handle error
});
Typescriptconst teamId: string = this.teamId
const teamType: V2NIMTeamType = this.teamType
const initNextToken: string = this.initNextToken
const order: V2NIMSortOrder = this.order
const limit: number = this.order
const keyword: string = this.keyword
const nextToken: string = this.nextToken
const options = {
keyword: keyword,
teamId: teamId,
teamType: teamType,
nextToken: nextToken,
initNextToken: initNextToken,
limit: limit,
order: order
} as V2NIMTeamMemberSearchOption
const result = await v2.teamService.searchTeamMembers(option)
Typescriptconst teamId: string = this.teamId
const teamType: V2NIMTeamType = this.teamType
const initNextToken: string = this.initNextToken
const order: V2NIMSortOrder = this.order
const limit: number = this.order
const keyword: string = this.keyword
const nextToken: string = this.nextToken
const options = {
keyword: keyword,
teamId: teamId,
teamType: teamType,
nextToken: nextToken,
initNextToken: initNextToken,
limit: limit,
order: order
} as V2NIMTeamMemberSearchOption
const res = await nim.teamService.searchTeamMembers(options)
返回参数
无返回值。
Promise<V2NIMTeamMemberSearchResult
>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调,包含V2NIMTeamMemberSearchResult
。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
- 请求成功,返回
V2NIMTeamMemberSearchResultCallback
回调,可自定义设置。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
addTeamMembersFollow
接口描述
在群组(包括高级群和超大群)设置免打扰的情况下,设置需要特别关注的群成员。设置完成后,仍能接收到特别关注成员的消息提醒。
调用成功后,会触发 onTeamMemberInfoUpdated
回调。
参数说明
Javavoid addTeamMembersFollow(String teamId,V2NIMTeamType teamType, List<String> accountIds, V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID。 |
teamType |
V2NIMTeamType |
是 | 群组类型。 |
accountIds |
List<String> | 是 | 需要特别关注的群成员账号 ID 列表。 |
success |
V2NIMSuccessCallback |
是 | 添加成功回调。 |
failure |
V2NIMFailureCallback |
是 | 添加失败回调,返回 错误码。 |
Objective-C- (void)addTeamMembersFollow:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
accountIds:(NSArray<NSString *> *)accountIds
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString | 是 | 群组 ID。 |
teamType |
V2NIMTeamType |
是 | 群组类型。 |
accountIds |
NSArray<NSString> | 是 | 需要特别关注的群成员账号 ID 列表。 |
success |
V2NIMSuccessCallback |
是 | 添加成功回调。 |
failure |
V2NIMFailureCallback |
是 | 添加失败回调,返回 错误码。 |
C++virtual void addTeamMembersFollow(const nstd::string& teamId,
V2NIMTeamType teamType,
const nstd::vector<nstd::string>& accountIds,
V2NIMSuccessCallback<void> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
nstd::string | 是 | 群组 ID。 |
teamType |
V2NIMTeamType |
是 | 群组类型。 |
accountIds |
nstd::vectornstd::string | 是 | 需要特别关注的群成员账号 ID 列表。 |
success |
V2NIMSuccessCallback |
是 | 添加成功回调。 |
failure |
V2NIMFailureCallback |
是 | 添加失败回调,返回 错误码。 |
TypeScriptaddTeamMembersFollow(teamId: string, teamType: V2NIMTeamType, accountIds: string[]): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。 |
teamType |
V2NIMTeamType |
是 | 群组类型。 |
accountIds |
string[] | 是 | 需要特别关注的群成员账号 ID 列表。 |
TypeScriptaddTeamMembersFollow(teamId, teamType, accountIds): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。 |
teamType |
V2NIMTeamType |
是 | 群组类型。 |
accountIds |
string[] | 是 | 需要特别关注的群成员账号 ID 列表。 |
TypeScriptaddTeamMembersFollow(teamId, teamType, accountIds): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。 |
teamType |
V2NIMTeamType |
是 | 群组类型。 |
accountIds |
string[] | 是 | 需要特别关注的群成员账号 ID 列表。 |
示例代码
JavaString teamId = "123456";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
List<String> accountIds = new ArrayList<>();
accountIds.add("test1");
accountIds.add("test2");
NIMClient.getService(V2NIMTeamService.class).addTeamMembersFollow(teamId, teamType, accountIds, new V2NIMSuccessCallback<Void>() {
@Override
public void onSuccess(Void unused) {
//addTeamMembersFollow success
}
}, new V2NIMFailureCallback() {
@Override
public void onFailure(V2NIMError error) {
//addTeamMembersFollow failed
}
});
Objective-C[[NIMSDK sharedSDK].v2TeamService addTeamMembersFollow:@"teamId"
teamType:V2NIM_TEAM_TYPE_NORMAL
accountIds:@[@"accountId1", @"accountId2"]
success:^{
// on success
} failure:^(V2NIMError * _Nonnull error) {
// on failure
}];
C++nstd::vector<nstd::string> accountIds;
accountIds.push_back("account1");
teamService.addTeamMembersFollow(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
accountIds,
[]() {
// add team members follow success
},
[](V2NIMError error) {
// add team members follow failed, handle error
});
TypeScriptconst teamId = "YOUR_TEAM_ID"
const teamType = 1 // "YOUR_TEAM_TYPE"
const accountIds = ["TARGET_ACCOUNT_ID"]
await nim.V2NIMTeamService.addTeamMembersFollow(teamId, teamType, accountIds)
TypeScriptawait v2.teamService.addTeamMembersFollow(teamId, teamType, accountIds)
TypeScriptconst teamId = "YOUR_TEAM_ID"
const teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL // "YOUR_TEAM_TYPE"
const accountIds = ["TARGET_ACCOUNT_ID_1", "TARGET_ACCOUNT_ID_2"]
await nim.teamService.addTeamMembersFollow(teamId, teamType, accountIds)
返回参数
无返回值。
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
removeTeamMembersFollow
接口描述
移除群组(包括高级群和超大群)中特别关注成员列表。移除成功后,当群组设置免打扰时,将无法接接收到消息提醒。
调用成功后,会触发 onTeamMemberInfoUpdated
回调。
参数说明
Javavoid removeTeamMembersFollow(String teamId,V2NIMTeamType teamType, List<String> accountIds, V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
String | 是 | 群组 ID。 |
teamType |
V2NIMTeamType |
是 | 群组类型。 |
accountIds |
List<String> | 是 | 需要移除的特别关注的群成员账号 ID 列表。 |
success |
V2NIMSuccessCallback |
是 | 移除成功回调。 |
failure |
V2NIMFailureCallback |
是 | 移除失败回调,返回 错误码。 |
Objective-C- (void)removeTeamMembersFollow:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
accountIds:(NSArray<NSString *> *)accountIds
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
NSString | 是 | 群组 ID。 |
teamType |
V2NIMTeamType |
是 | 群组类型。 |
accountIds |
NSArray<NSString> | 是 | 需要移除的特别关注的群成员账号 ID 列表。 |
success |
V2NIMSuccessCallback |
是 | 移除成功回调。 |
failure |
V2NIMFailureCallback |
是 | 移除失败回调,返回 错误码。 |
C++virtual void removeTeamMembersFollow(const nstd::string& teamId,
V2NIMTeamType teamType,
const nstd::vector<nstd::string>& accountIds,
V2NIMSuccessCallback<void> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
nstd::string | 是 | 群组 ID。 |
teamType |
V2NIMTeamType |
是 | 群组类型。 |
accountIds |
nstd::vector<nstd::string> | 是 | 需要移除的特别关注的群成员账号 ID 列表。 |
success |
V2NIMSuccessCallback |
是 | 移除成功回调。 |
failure |
V2NIMFailureCallback |
是 | 移除失败回调,返回 错误码。 |
TypeScriptremoveTeamMembersFollow(teamId: string, teamType: V2NIMTeamType, accountIds: string[]): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。 |
teamType |
V2NIMTeamType |
是 | 群组类型。 |
accountIds |
string[] | 是 | 需要移除的特别关注的群成员账号 ID 列表。 |
TypeScriptremoveTeamMembersFollow(teamId, teamType, accountIds): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。 |
teamType |
V2NIMTeamType |
是 | 群组类型。 |
accountIds |
string[] | 是 | 需要移除的特别关注的群成员账号 ID 列表。 |
TypeScriptremoveTeamMembersFollow(teamId, teamType, accountIds): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamId |
string | 是 | 群组 ID。 |
teamType |
V2NIMTeamType |
是 | 群组类型。 |
accountIds |
string[] | 是 | 需要移除的特别关注的群成员账号 ID 列表。 |
示例代码
JavaString teamId = "123456";
V2NIMTeamType teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL;
List<String> accountIds = new ArrayList<>();
accountIds.add("test1");
accountIds.add("test2");
NIMClient.getService(V2NIMTeamService.class).removeTeamMembersFollow(teamId, teamType, accountIds, new V2NIMSuccessCallback<Void>() {
@Override
public void onSuccess(Void unused) {
//removeTeamMembersFollow success
}
}, new V2NIMFailureCallback() {
@Override
public void onFailure(V2NIMError error) {
//removeTeamMembersFollow failed
}
});
Objective-C[[NIMSDK sharedSDK].v2TeamService removeTeamMembersFollow:@"teamId"
teamType:V2NIM_TEAM_TYPE_NORMAL
accountIds:@[@"accountId1", @"accountId2"]
success:^{
// on success
} failure:^(V2NIMError * _Nonnull error) {
// on failure
}];
C++nstd::vector<nstd::string> accountIds;
accountIds.push_back("account1");
teamService.removeTeamMembersFollow(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
accountIds,
[]() {
// remove team members follow success
},
[](V2NIMError error) {
// remove team members follow failed, handle error
});
TypeScriptconst teamId = "YOUR_TEAM_ID"
const teamType = 1 // "YOUR_TEAM_TYPE"
const accountIds = ["TARGET_ACCOUNT_ID"]
await nim.V2NIMTeamService.removeTeamMembersFollow(teamId, teamType, accountIds)
TypeScriptawait v2.teamService.removeTeamMembersFollow(teamId, teamType, accountIds)
TypeScriptconst teamId = "YOUR_TEAM_ID"
const teamType = V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL // "YOUR_TEAM_TYPE"
const accountIds = ["TARGET_ACCOUNT_ID"]
await nim.teamService.removeTeamMembersFollow(teamId, teamType, accountIds)
返回参数
无返回值。
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
clearAllTeamJoinActionInfo
接口描述
清空所有入群申请。
调用该方法,历史所有的入群申请数据均被清空。
参数说明
Javavoid clearAllTeamJoinActionInfo(V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
success |
V2NIMSuccessCallback |
是 | 清空成功回调。 |
failure |
V2NIMFailureCallback |
是 | 清空失败回调,返回 错误码。 |
Objective-C- (void)clearAllTeamJoinActionInfo:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
success |
V2NIMSuccessCallback |
是 | 清空成功回调。 |
failure |
V2NIMFailureCallback |
是 | 清空失败回调,返回 错误码。 |
C++virtual void clearAllTeamJoinActionInfo(const V2NIMSuccessCallback<void>& success, const V2NIMFailureCallback& failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
success |
V2NIMSuccessCallback |
是 | 清空成功回调。 |
failure |
V2NIMFailureCallback |
是 | 清空失败回调,返回 错误码。 |
TypeScriptclearAllTeamJoinActionInfo(): Promise<void>
无参数。
TypeScriptclearAllTeamJoinActionInfo(): Promise<void>
无参数。
TypeScriptclearAllTeamJoinActionInfo(): Promise<void>
无参数。
示例代码
JavaNIMClient.getService(V2NIMTeamService.class).clearAllTeamJoinActionInfo(new V2NIMSuccessCallback<Void>() {
@Override
public void onSuccess(Void unused) {
//success
}
}, new V2NIMFailureCallback() {
@Override
public void onFailure(V2NIMError error) {
//failed
}
});
Objective-C[[NIMSDK sharedSDK].v2TeamService clearAllTeamJoinActionInfo:^() {
//success
} failure:^(V2NIMError *error) {
//failed
}];
C++teamService.clearAllTeamJoinActionInfo(
[]() {
// clear all team join action info success
},
[](V2NIMError error) {
// clear all team join action info failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.clearAllTeamJoinActionInfo()
TypeScriptawait v2.teamService.clearAllTeamJoinActionInfo()
TypeScriptawait nim.teamService.clearAllTeamJoinActionInfo()
返回参数
无返回值。
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
deleteTeamJoinActionInfo
接口描述
删除指定的入群申请。
参数说明
Javavoid deleteTeamJoinActionInfo(V2NIMTeamJoinActionInfo application, V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
application |
V2NIMTeamJoinActionInfo |
是 | 申请入群的相关信息。 |
success |
V2NIMSuccessCallback |
是 | 删除成功回调。 |
failure |
V2NIMFailureCallback |
是 | 删除失败回调,返回 错误码。 |
Objective-C- (void)deleteTeamJoinActionInfo:(V2NIMTeamJoinActionInfo *)applicationInfo
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
是 | 申请入群的相关信息。 |
success |
V2NIMSuccessCallback |
是 | 删除成功回调。 |
failure |
V2NIMFailureCallback |
是 | 删除失败回调,返回 错误码。 |
C++virtual void deleteTeamJoinActionInfo(const V2NIMTeamJoinActionInfo& applicationInfo,
const V2NIMSuccessCallback<void>& success,
const V2NIMFailureCallback& failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
是 | 申请入群的相关信息。 |
success |
V2NIMSuccessCallback |
是 | 删除成功回调。 |
failure |
V2NIMFailureCallback |
是 | 删除失败回调,返回 错误码。 |
TypeScriptdeleteTeamJoinActionInfo(applicationInfo: V2NIMTeamJoinActionInfo): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
是 | 申请入群的相关信息。 |
TypeScriptdeleteTeamJoinActionInfo(applicationInfo): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
是 | 申请入群的相关信息。 |
TypeScriptdeleteTeamJoinActionInfo(applicationInfo: V2NIMTeamJoinActionInfo): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
是 | 申请入群的相关信息。 |
示例代码
JavaNIMClient.getService(V2NIMTeamService.class).deleteTeamJoinActionInfo(actionInfo,new V2NIMSuccessCallback<Void>() {
@Override
public void onSuccess(Void unused) {
//success
}
}, new V2NIMFailureCallback() {
@Override
public void onFailure(V2NIMError error) {
//failed
}
});
Objective-C[[NIMSDK sharedSDK].v2TeamService deleteTeamJoinActionInfo:actionInfo success:^() {
//success
} failure:^(V2NIMError *error) {
//failed
}];
C++V2NIMTeamJoinActionInfo applicationInfo;
// get applicationInfo from notification or query
// ...
teamService.deleteTeamJoinActionInfo(
applicationInfo,
[]() {
// delete team join action info success
},
[](V2NIMError error) {
// delete team join action info failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.deleteTeamJoinActionInfo(applicationInfo)
TypeScriptawait v2.teamService.deleteTeamJoinActionInfo(applicationInfo)
TypeScriptconst info: V2NIMTeamJoinActionInfo = {
actionType: V2NIMTeamJoinActionType.V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION,
teamId: '123456',
teamType: V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL,
operatorAccountId: 'ccc',
// 无用参数
timestamp: 123,
actionStatus: V2NIMTeamJoinActionStatus.V2NIM_TEAM_JOIN_ACTION_STATUS_INIT
}
await nim.teamService.deleteTeamJoinActionInfo(info)
返回参数
无返回值。
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
getJoinedTeamMembers
接口描述
查询自己加入的群组的成员信息列表。返回成员列表按照加入群组的时间戳(V2NIMTeamMember.joinTime
)排序。
参数说明
Javavoid getJoinedTeamMembers(List<V2NIMTeamType> teamTypes, V2NIMSuccessCallback<List<V2NIMTeamMember>> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamTypes |
List<V2NIMTeamType > |
否 | 群组类型,包括高级群和超大群。若不传,则查询所有群组类型。 |
success |
V2NIMSuccessCallback |
是 | 查询成功回调,返回 V2NIMTeamMember 列表。 |
failure |
V2NIMFailureCallback |
是 | 查询失败回调,返回 错误码。 |
Objective-C- (void)getJoinedTeamMembers:(nullable NSArray<NSNumber *> *)teamTypes
success:(nullable V2NIMTeamMemberListCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamTypes |
NSArray<NSNumber *> * | 否 | 群组类型,包括高级群和超大群。若不传,则查询所有群组类型。 |
success |
V2NIMTeamMemberListCallback |
是 | 查询成功回调,可自定义设置。 |
failure |
V2NIMFailureCallback |
是 | 查询失败回调,返回 错误码。 |
C++virtual void getJoinedTeamMembers(const nstd::vector<V2NIMTeamType>& teamTypes,
const V2NIMSuccessCallback<const nstd::vector<V2NIMTeamMember>&>& success,
const V2NIMFailureCallback& failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamTypes |
nstd::vector<V2NIMTeamType > |
否 | 群组类型,包括高级群和超大群。若不传,则查询所有群组类型。 |
success |
V2NIMSuccessCallback |
是 | 查询成功回调,返回 V2NIMTeamMember 列表。 |
failure |
V2NIMFailureCallback |
是 | 查询失败回调,返回 错误码。 |
TypeScriptgetJoinedTeamMembers(teamTypes?: V2NIMTeamType[]): Promise<V2NIMTeamMember[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamTypes |
V2NIMTeamType [] |
否 | 群组类型,包括高级群和超大群。若不传,则查询所有群组类型。 |
TypeScriptgetJoinedTeamMembers(teamTypes?: V2NIMTeamType[]): Promise<V2NIMTeamMember[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamTypes |
V2NIMTeamType [] |
否 | 群组类型,包括高级群和超大群。若不传,则查询所有群组类型。 |
TypeScriptgetJoinedTeamMembers(teamTypes?: V2NIMTeamType[]): Promise<V2NIMTeamMember[]>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
teamTypes |
V2NIMTeamType [] |
否 | 群组类型,包括高级群和超大群。若不传,则查询所有群组类型。 |
示例代码
Java// 获取自己所有加入的群的群成员信息(所有群类型)
List<V2NIMTeamType> teamTypes = null; // null表示查询所有群类型
NIMClient.getService(V2NIMTeamService.class).getJoinedTeamMembers(teamTypes,
new V2NIMSuccessCallback<List<V2NIMTeamMember>>() {
@Override
public void onSuccess(List<V2NIMTeamMember> teamMembers) {
System.out.println("获取群成员信息成功,共 " + teamMembers.size() + " 个成员");
// 按群组分类统计
Map<String, List<V2NIMTeamMember>> teamMemberMap = new HashMap<>();
for (V2NIMTeamMember member : teamMembers) {
String teamId = member.getTeamId();
if (!teamMemberMap.containsKey(teamId)) {
teamMemberMap.put(teamId, new ArrayList<>());
}
teamMemberMap.get(teamId).add(member);
}
System.out.println("涉及 " + teamMemberMap.size() + " 个群组:");
for (Map.Entry<String, List<V2NIMTeamMember>> entry : teamMemberMap.entrySet()) {
String teamId = entry.getKey();
List<V2NIMTeamMember> members = entry.getValue();
System.out.println("群组 " + teamId + " 有 " + members.size() + " 个成员");
// 显示每个成员的基本信息
for (V2NIMTeamMember member : members) {
String roleDesc = getMemberRoleDescription(member.getMemberRole());
System.out.println(" - " + member.getAccountId() +
" (" + roleDesc + ")" +
" 昵称: " + member.getTeamNick());
}
}
}
},
new V2NIMFailureCallback() {
@Override
public void onFailure(V2NIMError error) {
System.out.println("获取群成员信息失败, code: " + error.getCode() +
", message: " + error.getDesc());
}
}
);
Objective-CNSArray<NSNumber *> *teamTypes = @[
@(V2NIM_TEAM_TYPE_NORMAL),
@(V2NIM_TEAM_TYPE_SUPER)
];
[[NIMSDK sharedSDK].v2TeamService getJoinedTeamMembers:teamTypes
success:^(NSArray<V2NIMTeamMember *> * _Nonnull teamMembers) {
// getJoinedTeamMembers success
} failure:^(V2NIMError * _Nonnull error) {
// getJoinedTeamMembers failure
}];
C++nstd::vector<V2NIMTeamType> teamTypes;
teamTypes.push_back(V2NIM_TEAM_TYPE_NORMAL);
teamService.getJoinedTeamMembers(
teamTypes,
[](const nstd::vector<V2NIMTeamMember>& teamMembers) {
// get joined team members success
},
[](const V2NIMError& error) {
// get joined team members failed, handle error
});
TypeScriptawait nim.V2NIMTeamService.getJoinedTeamMembers([1])
TypeScriptconst members = await v2.teamService.getJoinedTeamMembers(teamTypes)
TypeScript// input
const teamTypes: V2NIMTeamType[] = [V2NIMTeamType.V2NIM_TEAM_TYPE_NORMAL]
// call interface
const memberList: V2NIMTeamMember[] = await teamService.getJoinedTeamMembers(teamTypes)
返回参数
无返回值。
Promise<V2NIMTeamMember
[]> 群成员列表
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调,包含V2NIMTeamMember
列表。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
- 请求成功,返回
V2NIMTeamMemberListCallback
回调,可自定义设置。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
setTeamJoinActionInfoRead
接口描述
设置群申请/邀请已读。
调用该方法,历史未读的群申请/邀请数据均标记为已读。
参数说明
Javavoid setTeamJoinActionInfoRead(V2NIMTeamJoinActionInfo application,V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
application |
V2NIMTeamJoinActionInfo |
否 | 入群申请的相关信息。传入 null,则标记所有的申请信息为已读;若不为 null,则标记单条申请信息。 |
success |
V2NIMSuccessCallback |
是 | 查询成功回调。 |
failure |
V2NIMFailureCallback |
是 | 查询失败回调,返回 错误码。 |
Objective-C- (void)setTeamJoinActionInfoRead:(nullable V2NIMTeamJoinActionInfo *)applicationInfo
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
否 | 入群申请的相关信息。传入 null,则标记所有的申请信息为已读;若不为 null,则标记单条申请信息。 |
success |
V2NIMSuccessCallback |
是 | 查询成功回调。 |
failure |
V2NIMFailureCallback |
是 | 查询失败回调,返回 错误码。 |
C++virtual void setTeamJoinActionInfoRead(const nstd::optional<V2NIMTeamJoinActionInfo>& applicationInfo,
const V2NIMSuccessCallback<void>& success,
const V2NIMFailureCallback& failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
否 | 入群申请的相关信息。传入 null,则标记所有的申请信息为已读;若不为 null,则标记单条申请信息。 |
success |
V2NIMSuccessCallback |
是 | 查询成功回调。 |
failure |
V2NIMFailureCallback |
是 | 查询失败回调,返回 错误码。 |
TypeScriptsetTeamJoinActionInfoRead(applicationInfo?: V2NIMTeamJoinActionInfo): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
否 | 入群申请的相关信息。传入 null,则标记所有的申请信息为已读;若不为 null,则标记单条申请信息。 |
TypeScriptsetTeamJoinActionInfoRead(applicationInfo: V2NIMTeamJoinActionInfo): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
否 | 入群申请的相关信息。传入 null,则标记所有的申请信息为已读;若不为 null,则标记单条申请信息。 |
TypeScriptsetTeamJoinActionInfoRead(applicationInfo?: V2NIMTeamJoinActionInfo): Promise<void>
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
applicationInfo |
V2NIMTeamJoinActionInfo |
否 | 入群申请的相关信息。传入 null,则标记所有的申请信息为已读;若不为 null,则标记单条申请信息。 |
示例代码
Java/**
* 示例1:标记特定群申请为已读
* 标记同一组(群ID,群type,且申请者相同)相关申请信息为已读
*/
public void markSpecificTeamJoinActionAsRead(V2NIMTeamJoinActionInfo actionInfo) {
NIMClient.getService(V2NIMTeamService.class).setTeamJoinActionInfoRead(
actionInfo, // 传入具体的申请信息
new V2NIMSuccessCallback<Void>() {
@Override
public void onSuccess(Void result) {
System.out.println("成功标记群申请为已读");
// 这里可以更新UI,比如刷新申请列表,移除未读标识等
onTeamJoinActionReadSuccess(actionInfo);
}
},
new V2NIMFailureCallback() {
@Override
public void onFailure(int code, String desc) {
System.err.println("标记群申请已读失败,错误码: " + code + ", 错误描述: " + desc);
// 处理失败情况,可能需要提示用户或重试
onTeamJoinActionReadFailed(code, desc);
}
}
);
}
Objective-C- (void)markTeamJoinActionAsRead:(V2NIMTeamJoinActionInfo *)actionInfo {
[[NIMSDK sharedSDK].V2NIMTeamService setTeamJoinActionInfoRead:actionInfo
success:^(id result) {
NSLog(@"成功标记群申请为已读");
} failure:^(NSInteger code, NSString * _Nullable desc) {
NSLog(@"标记群申请已读失败,错误码: %ld, 错误描述: %@", (long)code, desc);
}];
}
C++V2NIMTeamJoinActionInfo applicationInfo;
// get applicationInfo from notification or query
// ...
teamService.setTeamJoinActionInfoRead(
applicationInfo,
[]() {
// set team join action info read success
},
[](V2NIMError error) {
// set team join action info read failed, handle error
});
TypeScript// 1. 全量已读
await nim.V2NIMTeamService.setTeamJoinActionInfoRead()
// 2. 单条已读
const res: V2NIMTeamJoinActionInfoResult = await nim.V2NIMTeamService.getTeamJoinActionInfoList({})
if (res.infos.length > 0) {
const lastAction = res.infos[0] // get last join action info
await nim.V2NIMTeamService.setTeamJoinActionInfoRead(lastAction)
}
TypeScriptawait v2.teamService.setTeamJoinActionInfoRead()
TypeScript// 1. 全量已读
await nim.teamService.setTeamJoinActionInfoRead()
// 2. 单条已读
const res: V2NIMTeamJoinActionInfoResult = await nim.teamService.getTeamJoinActionInfoList({})
if (res.infos.length > 0) {
const lastAction = res.infos[0] // get last join action info
await nim.teamService.setTeamJoinActionInfoRead(lastAction)
}
返回参数
无返回值。
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。
getTeamJoinActionInfoUnreadCount
接口描述
获取未读的群申请/邀请(状态为未处理)数量。
参数说明
Javavoid getTeamJoinActionInfoUnreadCount(V2NIMSuccessCallback<Integer> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
success |
V2NIMSuccessCallback |
是 | 查询成功回调,返回未读群申请/邀请数量。 |
failure |
V2NIMFailureCallback |
是 | 查询失败回调,返回 错误码。 |
Objective-C- (void)getTeamJoinActionInfoUnreadCount:(nullable V2NIMTeamJoinActionInfoUnreadCountResultCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
success |
V2NIMTeamJoinActionInfoUnreadCountResultCallback |
是 | 查询成功回调,可自定义设置。 |
failure |
V2NIMFailureCallback |
是 | 查询失败回调,返回 错误码。 |
C++virtual void getTeamJoinActionInfoUnreadCount(const V2NIMSuccessCallback<uint32_t>& success, const V2NIMFailureCallback& failure) = 0;
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
success |
V2NIMSuccessCallback |
是 | 查询成功回调,返回未读群申请/邀请数量。 |
failure |
V2NIMFailureCallback |
是 | 查询失败回调,返回 错误码。 |
TypeScriptgetTeamJoinActionInfoUnreadCount(): Promise<number>
TypeScriptgetTeamJoinActionInfoUnreadCount(): Promise<number>
TypeScriptgetTeamJoinActionInfoUnreadCount(): Promise<number>
示例代码
JavaNIMClient.getService(V2NIMTeamService.class).getTeamJoinActionInfoUnreadCount(
new V2NIMSuccessCallback<Integer>() {
@Override
public void onSuccess(Integer unreadCount) {
System.out.println("群申请/邀请未读数量: " + unreadCount);
// 更新UI显示未读数量
updateUnreadCountUI(unreadCount);
}
},
new V2NIMFailureCallback() {
@Override
public void onFailure(int code, String desc) {
System.err.println("获取未读数量失败,错误码: " + code + ", 错误描述: " + desc);
// 处理获取失败的情况
onGetUnreadCountFailed(code, desc);
}
}
);
Objective-C[[NIMSDK sharedSDK].V2NIMTeamService getTeamJoinActionInfoUnreadCount:^(NSInteger unreadCount) {
NSLog(@"群申请/邀请未读数量: %ld", (long)unreadCount);
} failure:^(NSInteger code, NSString * _Nullable desc) {
NSLog(@"获取未读数量失败,错误码: %ld, 错误描述: %@", (long)code, desc);
}];
C++teamService.getTeamJoinActionInfoUnreadCount([](uint32_t code) {
// get team join action info unread count success
}, [](V2NIMError error) {
// handle error
});
TypeScriptconst unreadCount = await nim.V2NIMTeamService.getTeamJoinActionInfoUnreadCount();
TypeScriptconst count = await v2.teamService.getTeamJoinActionInfoUnreadCount()
TypeScriptconst unreadCount = await nim.teamService.getTeamJoinActionInfoUnreadCount()
返回参数
无返回值。
Promise<number>:未读的群申请/邀请数量
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调,包含未读的群申请/邀请数量。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
- 请求成功,返回
V2NIMTeamJoinActionInfoUnreadCountResultCallback
回调,可自定义设置。 - 请求失败,返回
V2NIMFailureCallback
回调,包含群组相关错误码。
无。