FriendshipGetBlackList

功能介绍

获取黑名单列表

参数详解

重载1

参数名称 参数类型 是否必填 描述
callback ValueCallback< List< FriendProfile > > 异步回调 返回值的json_param的格式为json

重载2

参数名称 参数类型 是否必填 描述
callback ValueCallback< string > 异步回调 返回值的json_param的格式为string

返回模板

TIMResult

调用成功后回调函数参数:
code:int
desc:string
json_param:
'[
  {
      "friend_profile_add_source" : "AddSource_Type_
      "friend_profile_add_time" : 1555656865,
      "friend_profile_add_wording" : "",
      "friend_profile_group_name_array" : [ "Group12
      "friend_profile_identifier" : "user10",
      "friend_profile_remark" : "",
      "friend_profile_user_profile" : {
        "user_profile_add_permission" : 0,
        "user_profile_birthday" : 0,
        "user_profile_face_url" : "",
        "user_profile_gender" : 0,
        "user_profile_identifier" : "user10",
        "user_profile_language" : 0,
        "user_profile_level" : 0,
        "user_profile_location" : "",
        "user_profile_nick_name" : "",
        "user_profile_role" : 0,
        "user_profile_self_signature" : ""
      }
  },
  {
      "friend_profile_add_source" : "",
      "friend_profile_add_time" : 0,
      "friend_profile_add_wording" : "",
      "friend_profile_group_name_array" : [],
      "friend_profile_identifier" : "user5",
      "friend_profile_remark" : "",
      "friend_profile_user_profile" : {
        "user_profile_add_permission" : 0,
        "user_profile_birthday" : 0,
        "user_profile_face_url" : "",
        "user_profile_gender" : 0,
        "user_profile_identifier" : "user5",
        "user_profile_language" : 0,
        "user_profile_level" : 0,
        "user_profile_location" : "",
        "user_profile_nick_name" : "",
        "user_profile_role" : 0,
        "user_profile_self_signature" : ""
      }
  }
]'// Json Key请参考[FriendProfile]
user_data:string

返回值详解

名称 数值类型 描述
TIMResult TIMResult 调用接口的返回值
code int 值为ERR_SUCC表示成功,其他值表示失败。详情请参考 错误码
desc string 错误描述字符串
json_param string Json字符串,不同的接口,Json字符串不一样 Json Key请参考FriendProfile
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.Linq;
using com.tencent.im.unity.demo.utils;
using System.Collections.Generic;

public class FriendshipGetBlackList : 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(FriendshipGetBlackListSDK);
    Copy.onClick.AddListener(CopyText);
  }
  void FriendshipGetBlackListSDK()
  {
    TIMResult res = TencentIMSDK.FriendshipGetBlackList(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();
  }
}

results matching ""

    No results matching ""