GroupGetJoinedGroupList
introduction
Get joined group list
Permission description:
Get all joined group list
AVChatRoom and Community (with topic) are not in the list.
Maximum calling 10 times per second. Once exceeded, it returns ERR_SDK_COMM_API_CALL_FREQUENCY_LIMIT (7008) error code.
If searching for Work group, send a message to initialize the group.
Parameter details
overload1
Parameter name | Parameter type | Required | Description |
---|---|---|---|
callback | ValueCallback< List< GroupBaseInfo > > | Required | Asynchronous callback The format of json_param in the return value is json |
overload2
Parameter name | Parameter type | Required | Description |
---|---|---|---|
callback | ValueCallback< string > | Required | Asynchronous callback The format of json_param in the return value is string |
Returned template
TIMResult
The parameters of the callback function after successfully calling the API:
code:int
desc:string
json_param:
'[
{
"group_base_info_face_url" : "group face url",
"group_base_info_group_id" : "first group id",
"group_base_info_group_name" : "first group name",
"group_base_info_group_type" : "Public",
"group_base_info_info_seq" : 7,
"group_base_info_is_shutup_all" : false,
"group_base_info_lastest_seq" : 0,
"group_base_info_msg_flag" : 0,
"group_base_info_readed_seq" : 0,
"group_base_info_self_info" : {
"group_self_info_join_time" : 1551344977,
"group_self_info_msg_flag" : 0,
"group_self_info_role" : 400,
"group_self_info_unread_num" : 0
}
}
]' // For the meaning of Json Key, please refer to [GroupBaseInfo]
user_data:string
Return value details
name | type | description |
---|---|---|
TIMResult | TIMResult | Return value of calling API |
code | int | Result error code: Error Codes |
desc | string | The description of the error. |
json_param | string | Json string. Calling different API will get different Json strings. For the meaning of Json Key, please refer to GroupBaseInfo |
user_data | string | User-defined data transfered by ImSDK without any processing |
Code example
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 com.tencent.im.unity.demo.utils;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class GroupGetJoinedGroupList : MonoBehaviour
{
public Text Header;
public Text Result;
public Button Submit;
public Button Copy;
public List<string> ResultText;
private string Data;
void Start()
{
// Result = GameObject.Find("ResultText").GetComponent<Text>();
Header = GameObject.Find("HeaderText").GetComponent<Text>();
Submit = GameObject.Find("Submit").GetComponent<Button>();
if (CurrentSceneInfo.info != null)
{
Header.text = Utils.IsCn() ? CurrentSceneInfo.info.apiText + " " + CurrentSceneInfo.info.apiName : CurrentSceneInfo.info.apiName;
Submit.GetComponentInChildren<Text>().text = CurrentSceneInfo.info.apiName;
}
Copy = GameObject.Find("Copy").GetComponent<Button>();
Copy.GetComponentInChildren<Text>().text = Utils.t("Copy");
Submit.onClick.AddListener(GroupGetJoinedGroupListSDK);
Copy.onClick.AddListener(CopyText);
}
void GroupGetJoinedGroupListSDK()
{
TIMResult res = TencentIMSDK.GroupGetJoinedGroupList(Utils.addAsyncStringDataToScreen(GetResult));
Result.text = Utils.SynchronizeResult(res);
}
void GenerateResultText()
{
var Parent = GameObject.Find("ResultPanel");
foreach (Transform child in Parent.transform)
{
GameObject.Destroy(child.gameObject);
}
foreach (string resultText in ResultText)
{
var obj = Instantiate(Result, Parent.transform);
obj.text = resultText;
}
}
void GetResult(params object[] parameters)
{
ResultText = new List<string>();
// ArgumentException: Mesh can not have more than 65000 vertices
// Deal with a single Text cannot render too many words issue
string CallbackData = (string)parameters[0];
string[] DataList = CallbackData.Split('\n');
int count = 0;
while (count < DataList.Length)
{
// Every 400 lines render a new Text
int end = count + 400;
if (end > DataList.Length)
{
end = DataList.Length;
}
string[] textList = DataList.Skip(count).Take(end - count).ToArray();
ResultText.Add(string.Join("\n", textList));
count = end;
}
Data = (string)parameters[0];
GenerateResultText();
}
void CopyText()
{
Utils.Copy(Data);
}
void OnApplicationQuit()
{
TencentIMSDK.Uninit();
}
}