GetLoginStatus

功能介绍

获取当前登陆状态

如果用户已经处于已登录和登录中状态,请勿再频繁调用登录接口登录

参数详解

此API无参数

返回模板

TIMLoginStatus

返回值详解

名称 数值类型 描述
TIMLoginStatus TIMLoginStatus 当前登陆状态

代码示例

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;

public class GetLoginStatus : 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(GetLoginStatusFromSDK);
    Copy.onClick.AddListener(CopyText);
  }
  void GetLoginStatusFromSDK()
  {
    var userid = PlayerPrefs.GetString("UserID", "");
    var user_sig = PlayerPrefs.GetString("Secret", "");
    TIMLoginStatus res = TencentIMSDK.GetLoginStatus();
    Result.text = res.ToString();
  }

  void GetResult(params object[] parameters)
  {
    Result.text += (string)parameters[0];
  }

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

results matching ""

    No results matching ""