- Android
- iOS
- JavaScript
- Flutter
- ReactNative
- HarmonyOS
Retrieve a paginated list of conversation information.
API Definition
/**
* Get the conversation information list by page. Results are sorted by conversation time in descending order (newest first and oldest last).
* @param count number of items to retrieve
* @param timestamp retrieval timestamp (pass 0 to use the current time)
* @param direction retrieval direction
* @return conversation information list
*/
List<ConversationInfo> getConversationInfoList(int count,
long timestamp,
JIMConst.PullDirection direction);
Code Example
List<ConversationInfo> list = JIM.getInstance().getConversationManager().getConversationInfoList(20, 0, JIMConst.PullDirection.OLDER);
Retrieve a paginated list of conversation information.
API Definition
/// Get the conversation information list by page. Results are sorted by conversation time in descending order (newest first and oldest last).
/// - Parameters:
/// - count: number of items to retrieve
/// - ts: retrieval timestamp (pass 0 to use the current time)
/// - direction: retrieval direction
- (NSArray<JConversationInfo *> *)getConversationInfoListByCount:(int)count
timestamp:(long long)ts
direction:(JPullDirection)direction;
Code Example
NSArray *array = [JIM.shared.conversationManager getConversationInfoListByCount:20 timestamp:0 direction:JPullDirectionOlder];
Parameters
| Name | Type | Required | Default | Description | Version |
|---|---|---|---|---|---|
| option | Object | No | 1.0.0 | ||
| option.count | Number | No | 50 | Retrieve the specified number of conversations, up to 100 conversations per request. | 1.0.0 |
| option.order | Number | No | FORWARD | Retrieval direction. Retrieves older or newer conversations; use with the time property. | 1.0.0 |
| option.time | Number | No | 0 | Retrieve conversations starting from the specified time. Use with order to retrieve older or newer conversations. | 1.0.0 |
Callback Parameters
| Property | Type | Description | Version |
|---|---|---|---|
| result | Object | Query result | 1.0.0 |
| result.conversations | Array | Conversation array. See Conversation for the structure of each conversation object. | 1.0.0 |
| result.isFinished | Boolean | Whether retrieval is complete | 1.0.0 |
Code Example
/*
Assume the current user has 199 conversations. Fetch 50 per page and sort the conversation list by time in descending order. Use the following pagination logic:
1. Page 1 retrieval options: { count: 50, time: 0 }
2. Page 2 retrieval options: { count: 50, time: 'the smallest sortTime in the page 1 conversation array (the conversation with the largest array index)' }
3. Page 3 retrieval options: { count: 50, time: 'the smallest sortTime in the page 2 conversation array (the conversation with the largest array index)' }
4. Page 4 retrieval options: { count: 50, time: 'the smallest sortTime in the page 3 conversation array (the conversation with the largest array index)' }
5. Finish: Stop loading when isFinished returns true
*/
jim.getConversations().then((result) => {
let { conversations, isFinished } = result;
console.log(isFinished, conversations);
})
Retrieve a paginated list of conversation information.
API Definition
//Callback definition
export type ConversationsCallback = (code:number,convers:ConversationInfo[])=>void
/**
* Get the conversation information list by page. Results are sorted by conversation time in descending or ascending order.
* @param count number of items to retrieve
* @param startTime starting timestamp (pass 0 to use the current time)
* @param isPositive retrieval direction; true for ascending and false for descending
* @return conversation information list
*/
queryConversations(count:number,startTime:number,isPositive:boolean,callback:ConversationsCallback)
Code Example
JuggleIm.instance.getConversationManager().queryConversations(10,0,false,(code,convers)=>{
})
Retrieve a paginated list of conversation information. Assume the current user has 199 conversations and retrieve 50 per page. The conversation list is sorted by time in descending order; implement pagination as follows:
- Load page 1 with:
{ count: 50, timestamp: 0 }
- Load page 2 with
timestampset to the smallestsortTimein the page 1 conversation array (the last array element).
- Load page 3 with
timestampset to the smallestsortTimein the page 2 conversation array (the last array element).
- Load page 4 with
timestampset to the smallestsortTimein the page 3 conversation array (the last array element).
- Stop loading when fewer than 50 conversations are returned.
Parameters
GetConversationInfoOption option = GetConversationInfoOption();
| Name | Type | Required | Default | Description | Version |
|---|---|---|---|---|---|
| option.count | int | No | 50 | Retrieve the specified number of conversations, up to 100 conversations per request. | 0.6.3 |
| option.timestamp | int | No | 0 | Retrieve conversations starting from the specified time. Use with direction to retrieve older or newer conversations. | 0.6.3 |
| option.direction | int | No | 0 | Retrieval direction. Retrieves older or newer conversations; use with the timestamp property. | 0.6.3 |
Code Example
GetConversationInfoOption option = GetConversationInfoOption();
option.count = 20;
option.timestamp = 0;
option.direction = 1; // 0: retrieve conversations after timestamp; 1: retrieve conversations before timestamp
List<ConversationInfo> conversations = await JuggleIm.instance.getConversationInfoListByOption(option);
Retrieve a paginated list of conversation information. Assume the current user has 199 conversations and retrieve 50 per page. The conversation list is sorted by time in descending order; implement pagination as follows:
- Load page 1 with:
{ count: 50, timestamp: 0 }
- Load page 2 with
timestampset to the smallestsortTimein the page 1 conversation array (the last array element).
- Load page 3 with
timestampset to the smallestsortTimein the page 2 conversation array (the last array element).
- Load page 4 with
timestampset to the smallestsortTimein the page 3 conversation array (the last array element).
- Stop loading when fewer than 50 conversations are returned.
Parameters
| Name | Type | Required | Default | Description | Version |
|---|---|---|---|---|---|
| count | Number | No | 50 | Retrieve the specified number of conversations, up to 100 conversations per request. | 1.0.0 |
| timestamp | Number | No | 0 | Retrieve conversations starting from the specified time. Use with direction to retrieve older or newer conversations. | 1.0.0 |
| direction | Number | No | 0 | Retrieval direction. Retrieves older or newer conversations; use with the timestamp property. | 1.0.0 |
Code Example
import JuggleIM from 'juggleim-rnsdk';
const conversations = await JuggleIM.getConversationInfoList({
count: 20,
timestamp: 0,
direction: 1 // 0: retrieve conversations after timestamp; 1: retrieve conversations before timestamp
});