setConversationDraft
Feature Introduction
Description
Set the conversation draft.
Note
Setting to empty will clear the draft.
Related Callback:
onConversationChanged
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future setConversationDraft({
required String conversationID,
required String draftText,
String? operationID,
})
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
conversationID | String | Yes | Conversation ID |
draftText | String | Yes | Draft content |
Return Result
Name | Type | Description |
---|---|---|
~ | ~ | Successful if no exception thrown |
Code Example
await OpenIM.iMManager.conversationManager.setConversationDraft(conversationID: conversationID, draftText: draftText);
//todo
Function Prototype
- (void)setConversationDraft:(NSString *)conversationID
draftText:(NSString *)draftText
onSuccess:(nullable OIMSuccessCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
conversationID | NSString | Yes | Conversation ID |
draftText | NSString | Yes | Draft content |
Return Result
Name | Type | Description |
---|---|---|
onSuccess | OIMSuccessCallback | Success return |
onFailure | OIMFailureCallback | Failure return |
Code Example
[OIMManager.manager setConversationDraft:@""
draftText:@""
onSuccess:^(NSString * _Nullable data) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void setConversationDraft(OnBase<String> base, String conversationID, String draftText)
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
base | OnBase<String> | Yes | Callback interface |
conversationID | String | Yes | Conversation ID |
draftText | String | Yes | Draft content |
Code Example
OpenIMClient.getInstance().conversationManager.setConversationDraft(new OnBase<String>() {
@Override
public void onError(int code, String error) {
}
@Override
public void onSuccess(String data) {
}
},conversationID,draftText);
Function Prototype
IMSDK.setConversationDraft({
conversationID: string;
draftText: string;
},operationID?: string): Promise<WsResponse>
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
conversationID | string | Yes | Conversation ID |
draftText | string | Yes | Draft content |
Return Result
Parameter Name | Data 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();
IMSDK.setConversationDraft({
conversationID: 'conversationID',
draftText: 'draft',
})
.then(({ data }) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
IMSDK.asyncApi('setConversationDraft', operationID: string, {
conversationID: string;
draftText: string;
}): Promise<void>
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes |
Operation ID, for troubleshooting. Recommended to use current time combined with random number | | conversationID | string | Yes | Conversation ID | | draftText | string | Yes | Draft content |
Return Result
The function is promisified through the
openim-uniapp-polyfill
package. Usethen
andcatch
to handle and determine success and failure callbacks.
Parameter Name | Data Type | Description |
---|---|---|
Promise.then() | Promise<void> | Success callback |
Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('setConversationDraft', IMSDK.uuid(), {
conversationID: '',
draftText: '',
})
.then(() => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
OpenIMSDKRN.setConversationDraft({
conversationID: string,
draftText: string,
}, operationID: string): Promise<void>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
conversationID | string | Yes | Conversation ID |
draftText | string | Yes | Draft content |
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";
OpenIMSDKRN.setConversationDraft({
conversationID: '',
draftText: '',
}, 'operationID')
.then(() => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
### Function Prototype
public static void SetConversationDraft(OnBase<bool> cb, string conversationId, string draftText)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | onBase | Yes | Callback |
conversationId | string | Yes | Conversation ID |
draftText | string | Yes | Draft content |
Code Example
IMSDK.SetConversationDraft((suc,errCode,errMsg)=>{
},conversationID,draftText);