setSelfInfo
Description
info
Modify the personal information of the currently logged-in user. Includes the Ex field.
Note
Related Callbacks:
onSelfInfoUpdated
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<String?> setSelfInfo({
String? nickname,
String? faceURL,
int? globalRecvMsgOpt,
String? ex,
String? operationID,
})
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| nickname | String? | No | User nickname |
| faceURL | String? | No | User avatar URL |
| globalRecvMsgOpt | int? | No | Global receive offline push settings |
| ex | String? | No | Extension information |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| ~ | ~ | Operation successful if no exception thrown |
Code Example
await OpenIM.iMManager.userManager.setSelfInfo(
nickname: 'lucy',
);
// todo
Function Prototype
- (void)setSelfInfo:(OIMUserInfo *)userInfo
onSuccess:(OIMSuccessCallback)onSuccess
onFailure:(OIMFailureCallback)onFailure;
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| userInfo | OIMUserInfo | Yes | User related information |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| onSuccess | OIMSuccessCallback | Success return |
| onFailure | OIMFailureCallback | Failure return |
Code Example
OIMUserInfo *info = [OIMUserInfo new];
info.nickname = @"";
info.faceURL = @"";
[OIMManager.manager setSelfInfo:info
onSuccess:^(NSString * _Nullable data) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void setSelfInfo(OnBase<String> base, UserInfoReq userInfoReq)
Input Parameters
The UserInfoReq request structure properties are as follows:
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| userID | String | Yes | User ID |
| nickname | String | No | User nickname |
| faceURL | String | No | User avatar |
| ex | String | No | Extension parameter |
| globalRecvMsgOpt | Integer | No | Global Do Not Disturb, 1: block messages; 2: receive messages but do not notify; 0: normal |
Return Result
Code Example
OpenIMClient.getInstance().userInfoManager.setSelfInfo(new OnBase<String>(){
@Override
public void onError(int code, String error) {
// todo: Handle error message
}
@Override
public void onSuccess(String data) {
// todo: Request successful
}
},userInfoReq);
Function Prototype
IMSDK.setSelfInfo(userInfo: Partial<Omit<SelfUserInfo, 'userID'>>, operationID?: string): Promise<WsResponse>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| userInfo | Partial<Omit<SelfUserInfo, 'userID'>> | Yes | Personal info |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<WsResponse> | Success callback |
| 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();
const userInfo = {
nickname: '', // Nickname to modify, optional
faceURL: '', // Avatar to modify, optional
ex: '', // Extension field content to modify, optional
};
IMSDK.setSelfInfo(userInfo)
.then(() => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
IMSDK.asyncApi('setSelfInfo', operationID: string, userInfo: Partial<Omit<SelfUserInfo, 'userID'>>): Promise<void>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| operationID | string | Yes | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
| userInfo | Partial<Omit<SelfUserInfo, 'userID'>> | Yes | Personal info |
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<void> | Success callback |
| Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
const userInfo = {
nickname: '', // Nickname to modify, optional
faceURL: '', // Avatar to modify, optional
ex: '', // Extension field content to modify, optional
};
IMSDK.asyncApi('setSelfInfo', IMSDK.uuid(), userInfo)
.then(() => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDK.setSelfInfo(
userInfo: Partial<SelfUserInfo>,
operationID?: string
): Promise<void>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| userInfo | Partial<SelfUserInfo> | Yes | Personal info |
| operationID | string | No | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<void> | Success callback |
| Promise.catch() | Promise<OpenIMApiError> | Failure callback |
Code Example
import OpenIMSDK from "@openim/rn-client-sdk";
const userInfo = {
nickname: '', // Nickname to modify, optional
faceURL: '', // Avatar to modify, optional
ex: '', // Extension field content to modify, optional
};
OpenIMSDK.setSelfInfo(userInfo)
.then(() => {
// Call successful
})
.catch((error) => {
// Call failed
});