- Android
- iOS
- JavaScript
- Flutter
- ReactNative
Add a Moment. Text, text and images, text and video, and images and video combinations are supported.
API Reference
/**
* publish a Moments post
* @param content text content of the Moments post
* @param mediaList list of media in the Moments post (images or videos)
* @param callback result callback
*/
void addMoment(String content, List<MomentMedia> mediaList, JIMConst.IResultCallback<Moment> callback);
Code Example
MomentMedia media1 = new MomentMedia();
media1.setType(MomentMedia.MomentMediaType.IMAGE);
media1.setUrl("www.baidu.com");
MomentMedia media2 = new MomentMedia();
media2.setType(MomentMedia.MomentMediaType.VIDEO);
media2.setUrl("www.google.com");
List<MomentMedia> l = new ArrayList<>();
l.add(media1);
l.add(media2);
JIM.getInstance().getMomentManager().addMoment("Beautiful!", l, new JIMConst.IResultCallback<Moment>() {
@Override
public void onSuccess(Moment moment) {
}
@Override
public void onError(int errorCode) {
}
});
Add a Moment. Text, text and images, text and video, and images and video combinations are supported.
API Reference
/// publish a Moments post
/// - Parameters:
/// - content: text content of the Moments post
/// - mediaList: list of media in the Moments post (images or videos)
/// - completeBlock: result callback
- (void)addMoment:(nonnull NSString *)content
mediaList:(nullable NSArray <JMomentMedia *> *)mediaList
complete:(nullable void (^)(JErrorCode errorCode, JMoment * _Nullable moment))completeBlock;
Code Example
NSMutableArray *mediaList = [NSMutableArray array];
JMomentMedia *media1 = [JMomentMedia new];
media1.type = JMomentMediaTypeImage;
media1.url = @"www.baidu.com";
JMomentMedia *media2 = [JMomentMedia new];
media2.type = JMomentMediaTypeVideo;
media2.url = @"www.google.com";
media2.snapshotUrl = @"www.google.com";
media2.width = 100;
media2.height = 100;
media2.duration = 100;
[mediaList addObject:media1];
[mediaList addObject:media2];
[JIM.shared.momentManager addMoment:@"Beautiful!" mediaList:mediaList complete:^(JErrorCode errorCode, JMoment * _Nullable moment) {
}];
Add a Moment. Text, text and images, text and video, and images and video combinations are supported.
API Reference
/**
* publish a Moments post
* @param content text content of the Moments post
* @param mediaList list of media in the Moments post (images or videos)
* return Moment object
*/
Future<Result<Moment>> addMoment(String content, List<MomentMedia>? mediaList) async
Code Example
String content = 'Beautiful!';
MomentMedia m1 = MomentMedia();
m1.url = 'www.baidu.com';
m1.type = 0;
m1.duration = 111;
m1.height = 300;
m1.width = 600;
MomentMedia m2 = MomentMedia();
m2.url = 'www.google.com';
m2.type = 1;
m2.duration = 222;
m2.height = 1080;
m2.width = 2000;
m2.snapshotUrl = 'snapshot.com';
List<MomentMedia> l = [m1, m2];
Result<Moment> result = await JuggleIm.instance.addMoment(content, l);
Add a Moment. Text, text and images, text and video, and images and video combinations are supported.
API Reference
/**
* publish a Moments post
* @param content text content of the Moments post
* @param mediaList list of media in the Moments post (images or videos)
* return Promise<Moment> object
*/
addMoment(content: string, mediaList?: MomentMedia[]): Promise<Moment>
Code Example
import { JuggleIMMoment } from 'juggleim-rnsdk';
const content = 'Today is a great day';
const mediaList = [
{
type: 'image',
url: 'http://example.com/image.jpg',
width: 100,
height: 100
}
];
const moment = await JuggleIMMoment.addMoment(content, mediaList);
console.log('Moments post added successfully', moment);
Add a Moment. Text, text and images, text and video, and images and video combinations are supported.
Parameters
| Name | Type | Required | Default | Description | Version |
|---|---|---|---|---|---|
| params | Object | Yes | - | Moment information | 1.9.6 |
| params.text | String | At least one of medias and text is required | - | Moment text content, up to 500 characters | 1.9.6 |
| params.medias | Array | At least one of medias and text is required | [] | Moment media content. Each element uses the Media structure. | 1.9.6 |
Callback Parameters
| Property | Type | Description | Version |
|---|---|---|---|
| result | Object | Query result | 1.9.6 |
| result.moment | Object | Moment object. See Moment. | 1.9.6 |
Code Example
// Publish a text-only Moments post
let content = {
text: 'This is a text-only Moments post'
};
jim.addMoment(content).then((result) => {
console.log('addMoment successfully', result)
});
// Publish a Moments post with text and images
let content = {
text: 'This is a Moments post with text and images',
medias: [
{
type: 'image',
url: 'https://example.com/image.jpg',
},
],
};
jim.addMoment(content).then((result) => {
console.log('addMoment successfully', result)
});