getSelfUserInfo
Description
info
Get the basic information of the currently logged-in user.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<UserInfo> getSelfUserInfo({
String? operationID,
})
Input Parameters
None
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| ~ | UserInfo | Success return |
Code Example
UserInfo info = await OpenIM.iMManager.userManager.getSelfUserInfo();
// todo
Function Prototype
- (void)getSelfInfoWithOnSuccess:(OIMUserInfoCallback)onSuccess
onFailure:(OIMFailureCallback)onFailure;
Input Parameters
None
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| onSuccess | OIMUserInfo | Success return |
| onFailure | OIMFailureCallback | Failure return |
Code Example
[OIMManager.manager getSelfInfoWithOnSuccess:^(OIMUserInfo * _Nullable userInfo) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void getSelfUserInfo(OnBase<UserInfo> callBack)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| callBack | OnBase<UserInfo> | Yes | Callback interface |
Code Example
OpenIMClient.getInstance().friendshipManager.getSelfUserInfo(new OnBase<UserInfo>(){…})
Function Prototype
IMSDK.getSelfUserInfo(operationID?: string): Promise<WsResponse<SelfUserInfo>>
Input Parameters
None
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<WsResponse<SelfUserInfo>> | User info object |
| 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.getSelfUserInfo()
.then(({ data }) => {
// data: Personal info of current logged-in user
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
IMSDK.asyncApi('getSelfUserInfo', operationID: string): Promise<SelfUserInfo>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| operationID | string | Yes | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
Return Result
Use the
openim-uniapp-polyfillpackage to make the function Promise. When calling, you need to usethenandcatchto determine and handle success and failure callbacks.
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<SelfUserInfo> | User info object |
| Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('getSelfUserInfo', IMSDK.uuid())
.then((data) => {
// data: Personal info of current logged-in user
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDK.getSelfUserInfo(operationID?: string): Promise<SelfUserInfo>
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<SelfUserInfo> | User info object |
| Promise.catch() | Promise<OpenIMApiError> | Failure callback |
Code Example
import OpenIMSDK from "@openim/rn-client-sdk";
OpenIMSDK.getSelfUserInfo()
.then((data) => {
// data: Personal info of current logged-in user
})
.catch((error) => {
// Call failed
});