markConversationMessageAsRead
Description
info
Mark a conversation as read.
- If the conversation type is single chat, this API is used to clear unread counts and send read receipts. After calling this API, the read status of messages sent by the counterparty will be updated.
- If the conversation type is group chat or notification, this API is only used to clear unread counts.
Note
Related Callbacks:
onConversationChanged
onRecvC2CReadReceipt
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future markConversationMessageAsRead({
required String conversationID,
String? operationID,
})
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| conversationID | String | Yes | Conversation ID |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | ~ | Operation successful if no exception thrown |
Code Example
await OpenIM.iMManager.messageManager.markMessageAsReadByConID(conversationID: '', messageIDList: []);
// todo
Function Prototype
- (void)markConversationMessageAsRead:(NSString *)conversationID
onSuccess:(nullable OIMSuccessCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| conversationID | NSString | Yes | Conversation ID |
Return Result
| Name | Type | Description |
|---|---|---|
| onSuccess | OIMSuccessCallback | Success return |
| onFailure | OIMFailureCallback | Failure return |
Code Example
[OIMManager.manager markConversationMessageAsRead:@""
onSuccess:^(NSString * _Nullable data) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void markMessageAsReadByConID(OnBase<String> callBack, String conversationID)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| callBack | OnBase<String> | Yes | Callback interface |
| conversationID | String | Yes | Conversation ID |
Code Example
OpenIMClient.getInstance().messageManager.markMessageAsReadByConID(new OnBase<String>() {
@Override
public void onError(int code, String error) {
}
@Override
public void onSuccess(String data) {
}
},conversationID);
Function Prototype
IMSDK.markConversationMessageAsRead(conversationID: string,operationID?: string): Promise<WsResponse>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| conversationID | string | Yes | Conversation ID |
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.markConversationMessageAsRead('conversationID')
.then(({ data }) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
IMSDK.asyncApi('markConversationMessageAsRead', operationID: string, conversationID: string): Promise<void>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| operationID | string | Yes | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
| conversationID | string | Yes | Conversation ID |
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('markConversationMessageAsRead', IMSDK.uuid(), 'conversationID')
.then(() => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDK.markConversationMessageAsRead(conversationID: string, operationID?: string): Promise<void>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| conversationID | string | Yes | Conversation ID |
| operationID | string | No | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
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.markConversationMessageAsRead('conversationID')
.then(() => {
// Call successful
})
.catch((error) => {
// Call failed
});
Function Prototype
public static void MarkConversationMessageAsRead(OnBase<bool> cb, string conversationId)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| cb | OnBase | Yes | Callback function |
| conversationId | string | Yes | Conversation ID |
Code Example
IMSDK.MarkConversationMessageAsRead((suc,errCode,errMsg)=>{
},conversationId);