setConversation
Description
info
Set conversation information, including pinned status, do-not-disturb status, ex, and other fields.
Note
Related Callbacks:
onConversationChanged
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future setConversation(
String conversationID,
ConversationReq req, {
String? operationID,
})
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| conversationID | String | Yes | Conversation ID |
| conversationReq | ConversationReq | Yes | Modified structural values |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | ~ | Operation successful if no exception thrown |
Code Example
await OpenIM.iMManager.conversationManager.setConversation(conversationID, req);
//todo
Function Prototype
- (void)setConversation:(NSString *)conversationID
req:(OIMConversationReq *)req
onSuccess:(nullable OIMSuccessCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| conversationID | NSString | Yes | Conversation ID |
| req | OIMConversationReq | Yes | Modified structural values |
Return Result
| Name | Type | Description |
|---|---|---|
| onSuccess | OIMSuccessCallback | Success return |
| onFailure | OIMFailureCallback | Failure return |
Code Example
[OIMManager.manager setConversation:@""
req: req
onSuccess:^(NSString * _Nullable data) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void setConversation(OnBase<String> base, String conversationID, ConversationReq conversationReq)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| conversationID | String | Yes | Conversation ID |
| conversationReq | ConversationReq | Yes | Modified structural values |
Return Result
Code Example
OpenIMClient.getInstance().conversationManager.setConversation(new OnBase<String>() {
@Override
public void onError(int code, String error) {
// todo: handle error information
}
@Override
public void onSuccess(String data) {
// todo: request successful
}
}, conversationID , conversationReq);
Function Prototype
IMSDK.setConversation({
conversationID: string;
recvMsgOpt?: MessageReceiveOptType;
groupAtType?: GroupAtType;
burnDuration?: number;
isPinned?: boolean;
isPrivateChat?: boolean;
ex?: string;
},operationID?: string): Promise<WsResponse>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| conversationID | string | Yes | Conversation ID |
| recvMsgOpt | MessageReceiveOptType | No | Receive message opt status |
| groupAtType | GroupAtType | No | Group at reminder type |
| isPinned | boolean | No | Whether the conversation is pinned |
| isPrivateChat | boolean | No | Whether burn-after-reading is enabled |
| burnDuration | number | No | Burn duration (seconds) |
| ex | string | No | Extension field |
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();
IMSDK.setConversation({
conversationID: 'conversationID',
isPinned: true,
})
.then(({ data }) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
IMSDK.asyncApi('setConversation', operationID: string, {
conversationID: string;
recvMsgOpt?: MessageReceiveOptType;
groupAtType?: GroupAtType;
burnDuration?: number;
isPinned?: boolean;
isPrivateChat?: boolean;
ex?: string;
}): Promise<void>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| conversationID | string | Yes | Conversation ID |
| recvMsgOpt | MessageReceiveOptType | No | Receive message opt status |
| groupAtType | GroupAtType | No | Group at reminder type |
| isPinned | boolean | No | Whether the conversation is pinned |
| isPrivateChat | boolean | No | Whether burn-after-reading is enabled |
| burnDuration | number | No | Burn duration (seconds) |
| ex | string | No | Extension field |
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';
IMSDK.asyncApi('setConversation', IMSDK.uuid(), {
conversationID: '',
isPinned: true,
})
.then(() => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDK.setConversation({
conversationID: string;
recvMsgOpt?: MessageReceiveOptType;
groupAtType?: GroupAtType;
burnDuration?: number;
isPinned?: boolean;
isPrivateChat?: boolean;
ex?: string;
}, operationID?: string): Promise<void>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| conversationID | string | Yes | Conversation ID |
| recvMsgOpt | MessageReceiveOptType | No | Receive message opt status |
| groupAtType | GroupAtType | No | Group at reminder type |
| isPinned | boolean | No | Whether the conversation is pinned |
| isPrivateChat | boolean | No | Whether burn-after-reading is enabled |
| burnDuration | number | No | Burn duration (seconds) |
| ex | string | No | Extension field |
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";
OpenIMSDK.setConversation(
{
conversationID: '',
isPinned: true,
}
)
.then(() => {
// Call successful
})
.catch((error) => {
// Call failed
});
Function Prototype
public static void SetConversation(OnBase<bool> cb, string conversationId, ConversationReq req)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| conversationId | string | Yes | Conversation ID |
| conversationReq | ConversationReq | Yes | Modified structural values |
Return Result
Code Example
IMSDK.SetConversation((suc,errCode,errMsg)=> {
}, conversationId , conversationReq);