Login API (Details) to log in.Login API are as follows:Parameter | Description | Remarks |
user_id | Unique user ID | It can contain up to 32 bytes of letters (a-z and A-Z), digits (0-9), underscores (_), and hyphens (-). |
user_sig | Login ticket | It is calculated by your business server to ensure security. For more information, see Generating UserSig. |
callback | Async callback |
Login API in the following scenarios:Login API returns the ERR_USER_SIG_EXPIRED (6206) or ERR_SVR_ACCOUNT_USERSIG_EXPIRED (70001) error code. In this case, you need to generate a new user_sig to log in again.UserSigExpiredCallback callback (Details) when users are online. In this case, you need to generate a new user_sig to log in again.KickedOfflineCallback callback (Details). In this case, you can prompt the user and call Login to log in again.Login API in the following scenarios:Login function, as the Chat SDK will automatically go online.public static void Login() {if (userid == "" || user_sig == ""){return;}TIMResult res = TencentIMSDK.Login(userid, user_sig, (int code, string desc, string json_param, string user_data)=>{// Process the login callback logic});
GetLoginUserID (Details) to get the UserID.
If the login fails, the UserID will be empty.public static void GetLoginUserID(){StringBuilder userId = new StringBuilder(128);TIMResult res = TencentIMSDK.GetLoginUserID(userId);Debug.Log(userId.ToString());}
GetLoginStatus (Details) to get the login status. If a user is logged in or logging in, don't call the login API frequently. The IM SDK supports the following login statuses:Login Status | Description |
kTIMLoginStatus_Logined | Logged in |
kTIMLoginStatus_Logining | Logging in |
kTIMLoginStatus_Logouting | Logging out |
kTIMLoginStatus_UnLogined | Not logged in |
public static void GetLoginStatus(){TIMLoginStatus res = TencentIMSDK.GetLoginStatus();}
Login API (Details) to log in, if the limit specified by the multi-client login policy for your account is exceeded, a newly logged in instance will kick out an earlier one.
The one kicked out will receive KickedOfflineCallback (Details).Logout API (Details) to log out of the SDK, after which you will no longer receive new messages. Note that in this case, you also need to call Uninit (Details) after the logout to uninitialize the SDK.public static void Logout(){TIMResult res = TencentIMSDK.Logout((int code, string desc, string json_param, string user_data)=>{// Process the logout callback logic});}
Alice to Bob, just call Login bob. You don't need to explicitly call logout alice, as this operation will be handled automatically inside the Chat SDK.Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan