- Android
- iOS
- JavaScript
- Flutter
- ReactNative
Get the Moments list for all friends. Pagination before or after a specified time is supported.
GetMomentOption structure
| Name | Type | Description | Version |
|---|---|---|---|
| count | int | Retrieve the specified number of Moments, up to 20 records per request | 1.8.30 |
| direction | JIMConst.PullDirection | Retrieval direction. Use startTime to retrieve older or newer Moments. | 1.8.30 |
| startTime | long | Start time for retrieving Moments. Use with direction; 0 uses the current time. | 1.8.30 |
| userId | String | Retrieve the Moments list published by a specified user. If empty, retrieves the Moments list for all friends. This parameter is supported only by getMomentList, not getCachedMomentList. | 1.8.44 |
API Reference
/**
* get the Moments list
* @param option retrieval options
* @param callback result callback
*/
void getMomentList(GetMomentOption option, JIMConst.IResultListCallback<Moment> callback);
Code Example
GetMomentOption o = new GetMomentOption();
o.setCount(10);
o.setStartTime(0);
o.setDirection(JIMConst.PullDirection.OLDER);
JIM.getInstance().getMomentManager().getMomentList(o, new JIMConst.IResultListCallback<Moment>() {
@Override
public void onSuccess(List<Moment> data, boolean isFinish) {
}
@Override
public void onError(int errorCode) {
}
});
Get Locally Cached Moments
/**
* Get the cached Moments list (cached data may not be the latest version; use it to render the UI immediately for a better user experience).
* @param option retrieval options
* @return cached Moments list
*/
List<Moment> getCachedMomentList(GetMomentOption option);
GetMomentOption o = new GetMomentOption();
o.setCount(10);
o.setStartTime(0);
o.setDirection(JIMConst.PullDirection.OLDER);
List<Moment> momentList = JIM.getInstance().getMomentManager().getCachedMomentList(o);
Get the Moments list for all friends. Pagination before or after a specified time is supported.
JGetMomentOption structure
| Name | Type | Description | Version |
|---|---|---|---|
| count | int | Retrieve the specified number of Moments, up to 20 records per request | 1.8.30 |
| direction | JPullDirection | Retrieval direction. Use startTime to retrieve older or newer Moments. | 1.8.30 |
| startTime | long long | Start time for retrieving Moments. Use with direction; 0 uses the current time. | 1.8.30 |
| userId | NSString | Retrieve the Moments list published by a specified user. If empty, retrieves the Moments list for all friends. This parameter is supported only by getMomentList, not getCachedMomentList. | 1.8.44 |
API Reference
/// get the Moments list
/// - Parameters:
/// - option: retrieval options
/// - completeBlock: result callback
- (void)getMomentList:(nonnull JGetMomentOption *)option
complete:(nullable void (^)(JErrorCode errorCode, NSArray <JMoment *> * _Nullable momentList, BOOL isFinish))completeBlock;
Code Example
JGetMomentOption *o = [JGetMomentOption new];
o.startTime = 0;
o.count = 10;
o.direction = JPullDirectionOlder;
[JIM.shared.momentManager getMomentList:o complete:^(JErrorCode errorCode, NSArray<JMoment *> * _Nullable momentList, BOOL isFinish) {
}];
Get Locally Cached Moments
/// Get the cached Moments list (cached data may not be the latest version; use it to render the UI immediately for a better user experience).
/// - Parameter option: retrieval options
- (NSArray <JMoment *> *_Nonnull)getCachedMomentList:(nonnull JGetMomentOption *)option;
JGetMomentOption *o = [JGetMomentOption new];
o.startTime = 0;
o.count = 10;
o.direction = JPullDirectionOlder;
NSArray *r = [JIM.shared.momentManager getCachedMomentList:o];
Get the Moments list for all friends. Pagination before or after a specified time is supported.
GetMomentOption structure
| Name | Type | Default | Description | Version |
|---|---|---|---|---|
| count | int | 10 | Retrieve the specified number of Moments, up to 20 records per request | 0.0.66 |
| direction | int | 1 | Retrieval direction (0 for newer records and 1 for older records). Use startTime to retrieve older or newer Moments. | 0.0.66 |
| startTime | int | 0 | Start time for retrieving Moments. Use with direction; 0 uses the current time. | 0.0.66 |
API Reference
/**
* get the Moments list
* @param o retrieval options
* return Moments list
*/
Future<ResultHasMore<List<Moment>>> getMomentList(GetMomentOption o) async
Code Example
GetMomentOption o = GetMomentOption();
ResultHasMore<List<Moment>> momentList = await JuggleIm.instance.getMomentList(o);
Get Locally Cached Moments
/**
* Get the cached Moments list (cached data may not be the latest version; use it to render the UI immediately for a better user experience).
* @param o retrieval options
* @return cached Moments list
*/
Future<List<Moment>> getCachedMomentList(GetMomentOption o) async
GetMomentOption o = GetMomentOption();
List<Moment> cachedMomentList = await JuggleIm.instance.getCachedMomentList(o);
Get the Moments list for all friends. Pagination before or after a specified time is supported.
GetMomentOption structure
| Name | Type | Default | Description | Version |
|---|---|---|---|---|
| count | number | 10 | Retrieve the specified number of Moments, up to 20 records per request | - |
| direction | number | 1 | Retrieval direction (0 for newer records and 1 for older records). Use startTime to retrieve older or newer Moments. | - |
| startTime | number | 0 | Start time for retrieving Moments. Use with direction; 0 uses the current time. | - |
| userId | string | Retrieve the Moments list published by a specified user. If empty, retrieves the Moments list for all friends. This parameter is supported only by getMomentList, not getCachedMomentList. | 0.3.1 |
API Reference
/**
* get the Moments list
* @param option retrieval options
* return Promise<{ list: Moment[], isFinished: boolean }>
*/
getMomentList(option: GetMomentOption): Promise<{ list: Moment[], isFinished: boolean }>
Code Example
import { JuggleIMMoment } from 'juggleim-rnsdk';
const o = {
count: 10,
startTime: 0,
direction: 1,
};
const momentList = await JuggleIMMoment.getMomentList(o);
Get Locally Cached Moments
/**
* Get the cached Moments list (cached data may not be the latest version; use it to render the UI immediately for a better user experience).
* @param option retrieval options
* @return cached Moments list
*/
getCachedMomentList(option: GetMomentOption): Promise<Moment[]>
import { JuggleIMMoment } from 'juggleim-rnsdk';
const o = {
count: 10,
startTime: 0,
direction: 1,
};
const cachedMomentList = await JuggleIMMoment.getCachedMomentList(o);
Get the Moments list for all friends. Pagination before or after a specified time is supported.
Parameters
| Name | Type | Required | Default | Description | Version |
|---|---|---|---|---|---|
| option | Object | No | 1.9.6 | ||
| option.count | Number | No | 50 | Retrieve the specified number of Moments, up to 20 records per request | 1.9.6 |
| option.order | Number | No | Retrieval direction | Retrieval direction. Use time to retrieve older or newer Moments. | 1.9.6 |
| option.time | Number | No | 0 | Start time for retrieving Moments. Use with order. | 1.9.6 |
| option.userId | String | No | - | Retrieve the Moments list published by a specified user. If empty, retrieves the Moments list for all friends. | 1.9.8 |
Callback Parameters
| Property | Type | Description | Version |
|---|---|---|---|
| result | Object | Query result | 1.9.6 |
| result.moments | Array | Moments array. See Moment. | 1.9.6 |
| result.isFinished | Boolean | Whether retrieval is complete | 1.9.6 |
Code Example
/*
Assume the current user has 79 Moments posts. Fetch 20 per page and sort the Moments list by time in descending order. Use the following pagination logic:
1. Page 1 retrieval options: { count: 20, time: 0 }
2. Page 2 retrieval options: { count: 20, time: 'the smallest momentTime in the page 1 Moments array' }
3. Page 3 retrieval options: { count: 20, time: 'the smallest momentTime in the page 2 Moments array' }
4. Page 4 retrieval options: { count: 20, time: 'the smallest momentTime in the page 3 Moments array' }
5. Finish: Stop loading when isFinished returns true
*/
jim.getMoments().then((result) => {
let { moments, isFinished } = result;
console.log(isFinished, moments);
})