markConversationMessageAsRead
Feature Introduction
Description
Mark the conversation as read.
- If the conversation type is a one-on-one chat, this interface is used to eliminate unread counts and send the read receipt for one-on-one chats. After calling this interface, the read status of messages sent by the other party will be updated.
- If the conversation type is a group chat, this interface is only used to eliminate unread counts.
- If the conversation type is a notification, this interface is only used to eliminate 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 { OpenIMSDK } from 'open-im-sdk';
// const IMSDK = new OpenIMSDK();
IMSDK.markConversationMessageAsRead('conversationID')
.then(({ data }) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
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 for problem localization, unique recommended using the current time and random number |
conversationID | string | Yes | Conversation ID |
Return Result
Using the
openim-uniapp-polyfill
package makes the function Promise-based. When calling, usethen
andcatch
to determine and handle successful and failed callbacks respectively.
| 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(() => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
OpenIMSDKRN.markConversationMessageAsRead(operationID: string, conversationID: string): Promise<void>
Input Parameters
Parameter Name | Parameter Name | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, used for problem location, keep unique, suggest using current time and random number |
conversationID | string | Yes | Conversation ID |
Return Result
Parameter Name | Parameter Name | 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.markConversationMessageAsRead('conversationID', 'operationID')
.then(() => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
public static void MarkConversationMessageAsRead(OnBase<bool> cb, string conversationId)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | OnBase | Yes | Callback |
conversationId | string | Yes | Conversation ID |
Code Example
IMSDK.MarkConversationMessageAsRead((suc,errCode,errMsg)=>{
},conversationId);