TIMLogout
Introduction
Logout
Call Logout when logout account or change account.
When changing the account, wait for Logout
callback return to call TIMLogin, otherwise TIMLogin may fail.
Normally, if your APP's lifecycle complies with IM SDK's, no need to Logout before leave the APP.
But for special cases, like you only Init IM SDK on certain scene, you should Logout
before leave the scene and you won't receive any messages. And you may call TIMUninit to uninit the SDK as well.
Call TIMLogin when you need to change account in your APP.
Parameter details
Parameter name | Parameter type | Required | Description |
---|---|---|---|
param | logoutParam | yes | Param of Logout operation |
Returned template
Promise<commonResult<string>>
{
code: TIMResult | TIMErrCode;
desc?: string | undefined;
json_param?: string | undefined;
json_params?: string | undefined;
user_data?: string | undefined;
}
Return value details
name | type | description |
---|---|---|
code | TIMResult | TIMErrCode | Request result: Error codes. 0 means success. |
desc | string | undefined | The description of the error. It will be empty if success. |
json_param | string | undefined | Return value of calling API |
json_params | string | undefined | Return value of calling API. Compatible field, which is returned in some cases. |
user_data | string | undefined | ImSDK is responsible for transporting user-defined data without any processing |
Code example
import TimRender from "im_electron_sdk/dist/renderer";
import { logoutParam } from "im_electron_sdk/dist/interfaces";
const timRenderInstance = new TimRender();
let param: logoutParam = {
userData: "logout" // optional
}
let { code } = await timRenderInstance.TIMLogout(param)
if (code == 0) {
// logout success
}