getAdvancedHistoryMessageList
Feature Introduction
Note
Retrieve the historical chat records from the latest message in a conversation.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<AdvancedMessage> getAdvancedHistoryMessageList({
String? conversationID,
int? lastMinSeq,
Message? startMsg,
int? count,
String? operationID,
})
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
conversationID | String | Yes | Conversation ID |
startMsg | Message | Yes | Query [count] messages starting from this message, index==length-1 is the latest message |
count | int | Yes | Number of messages |
lastMinSeq | int | Yes | Not required for the first page. Mandatory from the second page onward and similar to [startMsg] |
Return Result
Name | Type | Description |
---|---|---|
~ | AdvancedMessage | Successful return |
Code Example
AdvancedMessage am = await OpenIM.iMManager.messageManager.getAdvancedHistoryMessageList(
conversationID: '',
);
// todo
Function Prototype
- (void)getAdvancedHistoryMessageList:(OIMGetAdvancedHistoryMessageListParam *)opts
onSuccess:(nullable OIMGetAdvancedHistoryMessageListCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
OIMGetAdvancedHistoryMessageListParam.conversationID | NSString | Yes | Conversation ID. If not empty, retrieve by conversation ID, otherwise through userID and groupID |
OIMGetAdvancedHistoryMessageListParam.startClientMsgID | NSString | Yes | Starting message clientMsgID, first fetch is "" |
OIMGetAdvancedHistoryMessageListParam.count | NSInteger | Yes | Number of messages to fetch |
OIMGetAdvancedHistoryMessageListParam.lastMinSeq | NSInteger | Yes | lastMinSeq is the value returned from the previous fetch, context required for the second fetch onward |
Return Result
Name | Type | Description |
---|---|---|
onSuccess | NSArray< OIMGetAdvancedHistoryMessageListInfo * > | Successful return |
onFailure | OIMFailureCallback | Failure return |
Code Example
OIMGetAdvancedHistoryMessageListParam *opts = [OIMGetAdvancedHistoryMessageListParam new];
opts.conversationID = @"";
opts.count = 30;
opts.lastMinSeq = @"";
[OIMManager.manager getAdvancedHistoryMessageList:opts
onSuccess:^(OIMGetAdvancedHistoryMessageListInfo * _Nullable result) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void getAdvancedHistoryMessageList(OnBase<AdvancedMessage> callBack, String conversationID, Message startMsg, int count)
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
callBack | OnBase<AdvancedMessage> | Yes | Callback interface |
conversationID | String | Yes | Conversation ID |
startMsg | Message | Yes | Query [count] messages starting from this message, index==length-1 is the latest message |
count | int | Yes | Number of messages |
Code Example
OpenIMClient.getInstance().messageManager. getAdvancedHistoryMessageList(new OnBase<AdvancedMessage>() {
public void onError(int code, String error) {
}
public void onSuccess(AdvancedMessage data) {
}
} conversationID, startMsg, count);
// todo
Function Prototype
IMSDK.getAdvancedHistoryMessageList({
lastMinSeq: number;
count: number;
startClientMsgID: string;
conversationID: string;
}, operationID?: string): Promise<WsResponse<AdvancedGetMessageResult>>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
conversationID | string | Yes | Conversation ID |
startClientMsgID | string | Yes | Starting message clientMsgID, first fetch is "", subsequent fetch uses the last message's clientMsgID |
count | number | Yes | Number of messages to fetch |
lastMinSeq | number | Yes | lastMinSeq is the value returned from the previous fetch, context required for the second fetch onward |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse<AdvancedGetMessageResult>> | 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.getAdvancedHistoryMessageList({
lastMinSeq: 0,
count: 20,
startClientMsgID: '',
conversationID: 'conversationID',
})
.then(({ data }) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
IMSDK.asyncApi('getAdvancedHistoryMessageList', operationID: string, {
lastMinSeq: number;
count: number;
startClientMsgID: string;
conversationID: string;
}): Promise<AdvancedGetMessageResult>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, used for troubleshooting, keep unique, suggested to use the current time and a random number. |
conversationID | string | Yes | Conversation ID |
startClientMsgID | string | Yes | Starting message clientMsgID, "" for the first pull, and subsequent pulls use the last message's clientMsgID from the previous pull. |
count | number | Yes | Number of messages to pull each time |
lastMinSeq | number | Yes | lastMinSeq is the value returned from the last pull, context for the next pull |
Return Results
The function is made into a Promise using the
openim-uniapp-polyfill
package. Usethen
andcatch
to determine and handle the successful and failed callbacks.
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<AdvancedGetMessageResult> | Successful callback |
Promise.catch() | Promise<CatchResponse> | Failed callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('getAdvancedHistoryMessageList', IMSDK.uuid(), {
lastMinSeq: 0,
count: 20,
startClientMsgID: '',
conversationID: 'conversationID',
})
.then((data) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDKRN.getAdvancedHistoryMessageList({
lastMinSeq: number;
count: number;
startClientMsgID: string;
conversationID: string;
}, operationID: string): Promise<AdvancedGetMessageResult>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, used for troubleshooting, keep unique, suggested to use the current time and a random number. |
conversationID | string | Yes | Conversation ID |
startClientMsgID | string | Yes | Starting message clientMsgID, "" for the first pull, and subsequent pulls use the last message's clientMsgID from the previous pull. |
count | number | Yes | Number of messages to pull each time |
lastMinSeq | number | Yes | lastMinSeq is the value returned from the last pull, context for the next pull |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<AdvancedGetMessageResult> | Callback on successful call |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.getAdvancedHistoryMessageList({
lastMinSeq: 0,
count: 20,
startClientMsgID: '',
conversationID: 'conversationID',
}, 'operationID')
.then((data) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
public static void GetAdvancedHistoryMessageList(OnBase<AdvancedMessage> cb, GetAdvancedHistoryMessageListParams getMessageOptions)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | OnBase<AdvancedMessage> | Yes | Callback |
getMessageOptions | GetAdvancedHistoryMessageListParams | Yes | Option |
Code Example
IMSDK.GetAdvancedHistoryMessageList((historyMsgList,errCode,errMsg)=>{
},new GetAdvancedHistoryMessageListParams(){
});