GetLoginUserID

introduction

Get login user ID

Once logged in, call GetLoginUserID to acquire the current logged in user's UserID.

If login failed, return will be Null.

Input a StringBuilder along with the API, and the result UserID will be output to it.

Parameter details

Parameter name Parameter type Required Description
user_id StringBuilder yes StringBuilder for receiving user_id

Returned template

TIMResult

Return value details

name type description
TIMResult TIMResult Return value of calling API

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 EasyUI.Toast;
using com.tencent.im.unity.demo.utils;
using System.Text;

public class GetLoginUser : MonoBehaviour
{

  public Text Header;
  public Text Result;
  public Button Submit;
  public Button Copy;

  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(GetLoginUserSDK);
    Copy.onClick.AddListener(CopyText);
  }

  public void GetLoginUserSDK()
  {
    StringBuilder userId = new StringBuilder(128);
    TIMResult res = TencentIMSDK.GetLoginUserID(userId);
    Result.text = Utils.SynchronizeResult(res);
    Result.text += "\nLoginUser: " + userId.ToString();
  }

  void CopyText()
  {
    Utils.Copy(Result.text);
  }
  void OnApplicationQuit()
  {
    TencentIMSDK.Uninit();
  }
}

results matching ""

    No results matching ""