TencentImSDKPlugin.v2TIMManager.getGroupManager()
中。TencentImSDKPlugin.v2TIMManager.setGroupListener(listener: V2TimGroupListener());
// 创建public群,并指定相关群属性groupManager.createGroup(groupType: "Publich",groupName: "groupName",notification: "",introduction: "",faceUrl: "",isAllMuted: false,isSupportTopic: false,addOpt: GroupAddOptTypeEnum.V2TIM_GROUP_ADD_AUTH,memberList: [],);
类型 | 加群方法 |
好友工作群(Work) | 必须由其他群成员邀请 |
陌生人社交群(Public) | 用户申请,群主或管理员审批 |
临时会议群(Meeting) | 用户可随意加入 |
社群(Community) | 用户可随意加入 |
直播群(AVChatRoom) | 用户可随意加入 |
joinGroup
(Details) 加入群组。onMemberEnter
(Details) 回调。// 加入群组TencentImSDKPlugin.v2TIMManager.joinGroup(groupID: "groupID",message: "hello",groupType: "Public");// 监听加入群组事件TencentImSDKPlugin.v2TIMManager.addGroupListener(listener: V2TimGroupListener(onMemberEnter: ((groupID, memberList) {// 获取加入群的人员信息})));
inviteUserToGroup
(Details) 邀请另一个用户入群。onMemberInvited
(Details) 回调。您可以在这个回调中做一些 UI 上的提示。// 邀请 userA 用户进入群组 groupA 中groupManager.inviteUserToGroup(groupID: "groupID",userList:[]);// 监听群组邀请事件TencentImSDKPlugin.v2TIMManager.addGroupListener(listener: V2TimGroupListener(onMemberInvited: ((groupID, opUser, memberList) {// 获取邀请者、被邀请成员信息})));
joinGroup
(Details) 申请加群。onReceiveJoinApplication
(Details) ,在其中调用 getGroupApplicationList
(Details)获取加群申请列表。acceptGroupApplication
(Details) 同意加群,或调用 refuseGroupApplication
(Details) 拒绝加群请求。onApplicationProcessed
(Details) 回调。其中 isAgreeJoin
为 true
表示同意加群,反之被拒绝。onMemberEnter
(Details) 回调,通知群组成员有人进群。// ******群主端******//// 1、群主端修改加群选项为需要审核groupManager.setGroupInfo(info: V2TimGroupInfo.fromJson({"groupAddOpt":GroupAddOptTypeEnum.V2TIM_GROUP_ADD_AUTH}));// 2、群主端监听加群请求并处理TencentImSDKPlugin.v2TIMManager.addGroupListener(listener: V2TimGroupListener(onReceiveJoinApplication: (groupID, member, opReason) async {// 获取所有申请V2TimValueCallback<V2TimGroupApplicationResult> appls = await groupManager.getGroupApplicationList();appls.data.groupApplicationList.forEach((application) {// 同意groupManager.acceptGroupApplication(groupID: application.groupID, fromUser: application.fromUser, toUser: application.toUser,type: GroupApplicationTypeEnum.values[application.type]);// 拒绝groupManager.refuseGroupApplication(groupID: application.groupID, fromUser: application.fromUser, toUser: application.toUser, addTime: application.addTime, type: GroupApplicationTypeEnum.values[application.type]);});},));// ******用户端******//// 1、用户端申请加群TencentImSDKPlugin.v2TIMManager.joinGroup(groupID: "groupID",message: "hello",groupType: "Public");// 2、用户端监听加群审批结果TencentImSDKPlugin.v2TIMManager.addGroupListener(listener: V2TimGroupListener(onApplicationProcessed: ((groupID, opUser, isAgreeJoin, opReason) {// 加群申请被处理}),onMemberEnter:(groupID,memberlist){// 用户进群}));
setGroupInfo
(Details) 接口调整加群选项(V2TIMGroupAddOpt
),可以设置为更严格的 “禁止任何人加群”,也可以设置为更宽松的 “放开审批流程”。V2TIMGroupAddOpt
的可选项有:加群选项 | 含义 |
GroupAddOptTypeEnum.V2TIM_GROUP_ADD_FORBID | 禁止任何人加群 |
GroupAddOptTypeEnum.V2TIM_GROUP_ADD_AUTH | 需要群主或管理员审批才能加入(默认值) |
GroupAddOptTypeEnum.V2TIM_GROUP_ADD_ANY | 取消审批流程,任何用户都可以加入 |
getJoinedGroupList
(Details) 获取已加入的好友工作群(Work)、陌生人社交群(Public)、临时会议群(Meeting)、社群(Community,不支持话题功能)列表。但直播群(AVChatRoom)和 社群(Community,支持话题的社群)不包含在此列表中。// 获取已经加入的群组V2TimValueCallback<List<V2TimGroupInfo>> groupRes =await groupManager.getJoinedGroupList();
// 退出群组TencentImSDKPlugin.v2TIMManager.quitGroup(groupID: "groupID");TencentImSDKPlugin.v2TIMManager.addGroupListener(listener: V2TimGroupListener(onMemberLeave: (groupID, member) {// 离开群成员信息},));
// 解散群组TencentImSDKPlugin.v2TIMManager.dismissGroup(groupID: "groupID");// 事件监听TencentImSDKPlugin.v2TIMManager.addGroupListener(listener: V2TimGroupListener(onGroupDismissed: (groupID, opUser) {// 群被解散},onGroupRecycled: (groupID, opUser){// 群被回收}));
本页内容是否解决了您的问题?