getLoginStatus
Description
info
Get the user's login status. If this API is called while the SDK is not yet initialized, it will return -1001 (Uninitialized).
Note
Note the difference between connection status and login status. login can only be called when in the unlogged status.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<int?> getLoginStatus()
Input Parameters
None
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| ~ | int | Login status. 1: unlogged, 2: logging, 3: logged |
Code Example
int? status = await OpenIM.iMManager.getLoginStatus();
Function Prototype
- (OIMLoginStatus)getLoginStatus;
Input Parameters
None
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| status | OIMLoginStatus | Login status. 1: unlogged, 2: logging, 3: logged |
Code Example
OIMLoginStatus status = [OIMManager.manager getLoginStatus];
Function Prototype
public int getLoginStatus()
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| ~ | int | LoginStatus Login status |
Code Example
int status = OpenIMClient.getInstance().getLoginStatus();
Function Prototype
IMSDK.getLoginStatus(operationID?:string): Promise<WsResponse<LoginStatus>>;
Input Parameters
None
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<WsResponse<LoginStatus>> | Login status |
| Promise.catch() | Promise<WsResponse> | Failure callback |
Code Example
import { getSDK } from '@openim/wasm-client-sdk';
const IMSDK = getSDK();
// use in electron with ffi
// import { getWithRenderProcess } from '@openim/electron-client-sdk/lib/render';
// const { instance: IMSDK } = getWithRenderProcess();
// use in mini program
// import { getSDK } from '@openim/client-sdk';
// const IMSDK = getSDK();
IMSDK.getLoginStatus()
.then(({ data }) => {
// data: LoginStatus
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
IMSDK.asyncApi('getLoginStatus',operationID: string): Promise<LoginStatus>;
Input Parameters
None
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<LoginStatus> | Current user login status |
| Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('getLoginStatus', 'operationID');
.then((data) => {
// data: LoginStatus
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDK.getLoginStatus(operationID?: string): Promise<LoginStatus>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| operationID | string | No | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<LoginStatus> | Current user login status |
| Promise.catch() | Promise<OpenIMApiError> | Failure callback |
Code Example
import OpenIMSDK from "@openim/rn-client-sdk";
OpenIMSDK.getLoginStatus();
.then((data) => {
// data: LoginStatus
})
.catch((error) => {
// Call failed
});