GroupDelete
功能介绍
删除群
权限说明:
对于私有群,任何人都无法解散群组。
对于公开群、聊天室和直播大群,群主可以解散群组
删除指定群组group_id的接口,删除成功与否可根据回调cb的参数判断。
您可以调用 GroupDelete 解散群组,全员会收到 SetGroupTipsEventCallback 回调。
参数详解
重载1
参数名称 | 参数类型 | 是否必填 | 描述 |
---|---|---|---|
group_id | string | 是 | 群ID |
callback | NullValueCallback | 是 | 异步回调 |
重载2
参数名称 | 参数类型 | 是否必填 | 描述 |
---|---|---|---|
group_id | string | 是 | 群ID |
callback | ValueCallback< string > | 是 | 异步回调 返回值的json_param的格式为string |
返回模板
TIMResult
调用成功后回调函数参数:
code:int
desc:string
json_param:
'[
{
"group_delete_member_result_identifier" : "user2",
"group_delete_member_result_result" : 1
},
{
"group_delete_member_result_identifier" : "user3",
"group_delete_member_result_result" : 1
}
]'// Json Key请参考[GroupDeleteMemberResult]
user_data:string
返回值详解
名称 | 数值类型 | 描述 |
---|---|---|
TIMResult | TIMResult | 调用接口的返回值 |
code | int | 值为ERR_SUCC表示成功,其他值表示失败。详情请参考 错误码 |
desc | string | 错误描述字符串 |
json_param | string | Json字符串,不同的接口,Json字符串不一样 Json Key请参考GroupDeleteMemberResult |
user_data | string | ImSDK负责透传的用户自定义数据,未做任何处理 |
代码示例
using UnityEngine;
using UnityEngine.UI;
using com.tencent.im.unity.demo.types;
using com.tencent.imsdk.unity;
using com.tencent.imsdk.unity.types;
using com.tencent.imsdk.unity.enums;
using System;
using com.tencent.im.unity.demo.utils;
using EasyUI.Toast;
using System.Collections;
using System.Collections.Generic;
public class GroupDelete : MonoBehaviour
{
public Text Header;
public Dropdown SelectedGroup;
public Text Result;
public Button Submit;
public Button Copy;
private List<string> GroupList;
void Start()
{
GameObject.Find("SelectGroupLabel").GetComponent<Text>().text = Utils.t("SelectGroupLabel");
GroupGetJoinedGroupListSDK();
Header = GameObject.Find("HeaderText").GetComponent<Text>();
SelectedGroup = GameObject.Find("Dropdown").GetComponent<Dropdown>();
Result = GameObject.Find("ResultText").GetComponent<Text>();
Submit = GameObject.Find("Submit").GetComponent<Button>();
Copy = GameObject.Find("Copy").GetComponent<Button>();
Copy.GetComponentInChildren<Text>().text = Utils.t("Copy");
Submit.onClick.AddListener(GroupDeleteSDK);
Copy.onClick.AddListener(CopyText);
SelectedGroup.interactable = true;
if (CurrentSceneInfo.info != null)
{
Header.text = Utils.IsCn() ? CurrentSceneInfo.info.apiText + " " + CurrentSceneInfo.info.apiName : CurrentSceneInfo.info.apiName;
Submit.GetComponentInChildren<Text>().text = CurrentSceneInfo.info.apiName;
}
}
void GetGroupList(params object[] parameters)
{
try
{
GroupList = new List<string>();
SelectedGroup.ClearOptions();
string text = (string)parameters[1];
List<GroupBaseInfo> List = Utils.FromJson<List<GroupBaseInfo>>(text);
foreach (GroupBaseInfo item in List)
{
print(item.group_base_info_group_id);
GroupList.Add(item.group_base_info_group_id);
Dropdown.OptionData option = new Dropdown.OptionData();
option.text = item.group_base_info_group_id;
SelectedGroup.options.Add(option);
}
SelectedGroup.value = 0;
if (List.Count > 0)
{
SelectedGroup.captionText.text = List[0].group_base_info_group_id;
}
else
{
SelectedGroup.captionText.text = "";
}
}
catch (Exception ex)
{
Toast.Show(Utils.t("getGroupListFailed"));
}
}
void GroupGetJoinedGroupListSDK()
{
TIMResult res = TencentIMSDK.GroupGetJoinedGroupList(Utils.addAsyncStringDataToScreen(GetGroupList));
print($"GroupGetJoinedGroupListSDK {res}");
}
void GroupDeleteSDK()
{
if (GroupList.Count < 1)
{
return;
}
print(GroupList[SelectedGroup.value]);
string groupID = GroupList[SelectedGroup.value];
TIMResult res = TencentIMSDK.GroupDelete(groupID, Utils.addAsyncNullDataToScreen(GetResult));
Result.text = Utils.SynchronizeResult(res);
}
void GetResult(params object[] parameters)
{
GroupGetJoinedGroupListSDK();
Result.text += (string)parameters[0];
}
void CopyText()
{
Utils.Copy(Result.text);
}
void OnApplicationQuit()
{
TencentIMSDK.Uninit();
}
}