getSelfUserInfo
Feature Introduction
Description
Retrieve the logged-in userID, nickname, and avatar.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<UserInfo> getSelfUserInfo({
String? operationID,
})
Input Parameters
None
Return Value
Parameter Name | Parameter Type | Description |
---|---|---|
~ | UserInfo | Successful return |
Code Example
UserInfo info = await OpenIM.iMManager.userManager.getSelfUserInfo();
// todo
Function Prototype
- (void)getSelfInfoWithOnSuccess:(OIMUserInfoCallback)onSuccess
onFailure:(OIMFailureCallback)onFailure;
Input Parameters
None
Return Value
Parameter Name | Parameter Type | Description |
---|---|---|
onSuccess | OIMUserInfo | Successful return |
onFailure | OIMFailureCallback | Failed 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 | Mandatory | Description |
---|---|---|---|
callBack | OnBase< UserInfo> | Yes | Callback interface |
Return Value
Code Example
OpenIMClient.getInstance().friendshipManager.getSelfUserInfo(new OnBase<UserInfo>(){…})
Function Prototype
IMSDK.getSelfUserInfo(operationID?: string): Promise<WsResponse<SelfUserInfo>>
Input Parameters
None
Return Value
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse<SelfUserInfo>> | User information 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 { OpenIMSDK } from 'open-im-sdk';
// const IMSDK = new OpenIMSDK();
IMSDK.getSelfUserInfo()
.then(({ data }) => {
// data: Logged-in user's information
})
.catch(({ errCode, errMsg }) => {
// Failed to call
});
Function Prototype
IMSDK.asyncApi('getSelfUserInfo', operationID: string): Promise<SelfUserInfo>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID used to pinpoint issues. Unique, recommended using current time and a random number |
Return Value
The function is made into a Promise through the
openim-uniapp-polyfill
package. Usethen
andcatch
to determine and handle success and failure callbacks.
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<SelfUserInfo> | User information object |
Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('getSelfUserInfo', IMSDK.uuid())
.then((data) => {
// data: Logged-in user's information
})
.catch(({ errCode, errMsg }) => {
// Failed to call
});
Function Prototype
OpenIMSDKRN.getSelfUserInfo(operationID: string): Promise<SelfUserInfo>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, used for problem location, keep unique, suggest using current time and random number |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<SelfUserInfo> | User information object |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.getSelfUserInfo('operationID')
.then((data) => {
// data: Logged-in user's information
})
.catch(({ errCode, errMsg }) => {
// Failed to call
});