getLoginUserID
Feature Introduction
Description
Retrieve the userID of the currently logged-in user.
Note
Ensure to call this interface after a successful login callback.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<String> getLoginUserID()
Input Parameters
None
Return Value
Parameter Name | Type | Description |
---|---|---|
~ | String | User ID |
Code Example
String userID = await OpenIM.iMManager.getLoginUserID();
Function Prototype
- (NSString *)getLoginUserID;
Input Parameters
None
Return Value
Parameter Name | Type | Description |
---|---|---|
NSString | userID | User ID |
Code Example
NSString *userID = [OIMManager.manager getLoginUserID];
Function Prototype
public String getLoginUserID()
Return Value
Parameter Name | Type | Description |
---|---|---|
String | userID | User ID |
Code Example
String userID = OpenIMClient.getInstance().getLoginUserID();
Function Prototype
IMSDK.getLoginUserID(operationID?: string): Promise<WsResponse<string>>;
Input Parameters
None
Return Value
Parameter Name | Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse<string>> | Current logged-in user ID |
Promise.catch() | Promise<WsResponse> | Callback for call failure |
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.getLoginUserID()
.then(({ data }) => {
// data: Current logged-in userID
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
IMSDK.asyncApi("getLoginUserID",operationID: string): Promise<string>;
Input Parameters
None
Return Value
Parameter Name | Type | Description |
---|---|---|
Promise.then() | Promise<string> | Current logged-in user ID |
Promise.catch() | Promise<CatchResponse> | Callback for call failure |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('getLoginUserID', 'operationID')
.then((data) => {
// data: Current logged-in userID
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDKRN.getLoginUserID(operationID: string): Promise<string>
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<string> | Current logged-in user ID |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.getLoginUserID("operationID");
.then((data) => {
// data: Current logged-in userID
})
.catch(({ errCode, errMsg }) => {
// Call failed
});