setSelfInfo
Feature Introduction
Allows logged-in users to modify their own avatar and nickname.
Related Callback: 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 | Mandatory | Description |
---|---|---|---|
nickname | String? | No | User nickname |
faceURL | String? | No | User avatar |
globalRecvMsgOpt | int? | No | Global offline push settings |
ex | String? | No | Extension information |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
~ | ~ | If no exception is thrown, the modification is successful |
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 | Mandatory | 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
UserInfoReq: | Parameter Name | Parameter Type | Mandatory | Description | | ---------------- | ------------------------------------ | --------- | ------------------------------------ | | userID | String | Yes | Name | | nickname | String | No | Nickname | | faceURL | String | No | Avatar | | ex | String | No | Internal field, can be ignored | | globalRecvMsgOpt | Integer | No | Global Do Not Disturb 0: Normal; 1: Do not receive messages; 2: Receive online messages but not offline messages |
Return Result
Code Example
OpenIMClient.getInstance().userInfoManager.setSelfInfo(new OnBase<String>(){
@Override
public void onError(int code, String error) {
// todo: request error
}
@Override
public void onSuccess(String data) {
// todo: request success
}
},userInfoReq);
Function Prototype
IMSDK.setSelfInfo(userInfo: Partial<Omit<SelfUserInfo, 'userID'>>, operationID?: string): Promise<WsResponse>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
userInfo | Partial<Omit<SelfUserInfo, 'userID'>> | Yes | Personal information |
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 { OpenIMSDK } from 'open-im-sdk';
// const IMSDK = new OpenIMSDK();
const userInfo = {
nickname: '', // Desired nickname, optional
faceURL: '', // Desired avatar, optional
ex: '', // Desired extension field content, 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 | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID used for troubleshooting, keep unique. It is recommended to use the current time combined with a random number |
userInfo | Partial<Omit<SelfUserInfo, 'userID'>> | Yes | Personal information |
Return Result
The function is made Promise-based through the
openim-uniapp-polyfill
package. When calling, usethen
andcatch
to determine and handle the 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: '', // Desired nickname, optional
faceURL: '', // Desired avatar, optional
ex: '', // Desired extension field content, optional
};
IMSDK.asyncApi('setSelfInfo', IMSDK.uuid(), userInfo)
.then(() => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDKRN.setSelfInfo(
userInfo: Partial<Omit<SelfUserInfo, 'userID'>>, // Replace with the actual structure of userInfo
operationID: string
);
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
userInfo | Partial<Omit<SelfUserInfo, 'userID'>> | Yes | Personal information |
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<void> | Callback on successful call |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
const userInfo = {
nickname: '', // Desired nickname, optional
faceURL: '', // Desired avatar, optional
ex: '', // Desired extension field content, optional
};
OpenIMSDKRN.setSelfInfo(userInfo, 'operationID');
.then(() => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});