deleteMessage
Feature Introduction
Description
Delete a message from both local and server.
Note
Related Callback: onConversationChanged If the deleted message is the latest one, the most recent message in the conversation will change.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<dynamic> deleteMessageFromLocalAndSvr({
required String conversationID,
required String clientMsgID,
String? operationID,
})
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
conversationID | String | Yes | Conversation ID |
clientMsgID | String | Yes | Message ID |
Return Result
Name | Type | Description |
---|---|---|
~ | ~ | Operation successful if no exceptions thrown |
Code Example
await OpenIM.iMManager.messageManager.deleteMessageFromLocalAndSvr(
"conversationID":"conversationID",
"clientMsgID":"clientMsgID",
);
// todo
Function Prototype
- (void)deleteMessage:(NSString *)conversationID
clientMsgID:(NSString *)clientMsgID
onSuccess:(nullable OIMSuccessCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
conversationID | NSString | Yes | Conversation ID |
clientMsgID | NSString | Yes | Message ID |
Return Result
Name | Type | Description |
---|---|---|
onSuccess | OIMSuccessCallback | Successful Return |
onFailure | OIMFailureCallback | Failure Return |
Code Example
[OIMManager.manager deleteMessage:@""
clientMsgID:@""
onSuccess:^(NSString * _Nullable data) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void deleteMessageFromLocalAndSvr(String conversationID, String clientMsgID, OnBase<String> callBack)
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
conversationID | String | Yes | Conversation ID |
clientMsgID | String | Yes | Message ID |
callBack | OnBase<String> | Yes | Callback Interface |
Return Result
Name | Type | Description |
---|---|---|
~ | ~ | Operation successful if no exceptions thrown |
Code Example
OpenIMClient.getInstance().messageManager. deleteMessageFromLocalAndSvr(conversationID, clientMsgID,new OnBase<String>() {
public void onError(int code, String error) {
}
public void onSuccess(String data) {
}
})
// todo
Function Prototype
IMSDK.deleteMessage({
conversationID: string;
clientMsgID: string;
}, operationID?: string): Promise<WsResponse>
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
conversationID | string | Yes | Conversation ID |
clientMsgID | string | Yes | Message ID |
Return Result
Parameter Name | Data Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse> | Successful 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.deleteMessage({
conversationID: '',
clientMsgID: '',
})
.then(({ data }) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
IMSDK.asyncApi('deleteMessage', operationID: string, {
conversationID: string;
clientMsgID: string;
}): Promise<void>
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, for troubleshooting, unique, suggested to use current time and random number |
conversationID | string | Yes | Conversation ID |
clientMsgID | string | Yes | Message ID |
Return Result
Through the
openim-uniapp-polyfill
package, the function is made Promise-based. When calling, you need to usethen
andcatch
to determine and handle successful and failed callbacks.
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<void> | Successful callback |
Promise.catch() | Promise<CatchResponse> | Failed callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('deleteMessage', IMSDK.uuid(), {
conversationID: '',
clientMsgID: '',
})
.then(() => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
OpenIMSDKRN.deleteMessage({
conversationID: string,
clientMsgID:string
}, operationID: string): Promise<void>
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, for troubleshooting, unique, suggested to use current time and random number |
conversationID | string | Yes | Conversation ID |
clientMsgID | string | Yes | Message ID |
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.deleteMessage({
conversationID: '',
clientMsgID: '',
}, 'operationID')
.then(() => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
### Function Prototype
public static void DeleteMessage(OnBase<bool> cb, string conversationId, string clientMsgId)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | OnBase | Yes | Callback |
conversationId | string | Yes | Conversation ID |
clientMsgId | string | Yes | Message ID |
Return Result
Code Example
IMSDK.DeleteMessage((suc,errCode,errMsg)=>{
},conversationId,clientMsgId);