setSelfInfo
Feature Introduction
Description
Allows logged-in users to modify their own avatar and nickname.(This interface is deprecated. Please use setSelfInfoEx
)
Note
Related Callback: onSelfInfoUpdated
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<String?> setSelfInfo({
String? nickname,
String? faceURL,
int? appMangerLevel,
String? ex,
String? operationID,
})
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
nickname | String? | No | User nickname |
faceURL | String? | No | User avatar |
appMangerLevel | int? | No | Internal field, can be ignored |
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> callBack, String nickname, String faceURL, int appMangerLevel, String ex)
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
callBack | OnBase | Yes | Callback interface |
nickname | String | Yes | Name |
faceURL | String | Yes | Avatar |
gender | int | Yes | Gender 1: Male, 2: Female |
appMangerLevel | int | Yes | Internal field, can be ignored |
ex | String | No | Extension field |
Return Result
Code Example
OpenIMClient.getInstance().userInfoManager.setSelfInfo(new OnBase<String>(){…},...);
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 'open-im-sdk-wasm';
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
});