- Android
- iOS
- JavaScript
- Flutter
- ReactNative
Add a comment. Replies to another user's comment are also supported.
API Reference
/**
* post a comment
* @param momentId ID of the Moments post being commented on
* @param parentCommentId parent comment ID; may be empty
* @param content comment content
* @param callback result callback
*/
void addComment(String momentId, String parentCommentId, String content, JIMConst.IResultCallback<MomentComment> callback);
Code Example
// "parentCommentId" may be empty
JIM.getInstance().getMomentManager().addComment("momentId", "parentCommentId", "Good picture!", new JIMConst.IResultCallback<MomentComment>() {
@Override
public void onSuccess(MomentComment data) {
}
@Override
public void onError(int errorCode) {
}
});
Add a comment. Replies to another user's comment are also supported.
API Reference
/// post a comment
/// - Parameters:
/// - momentId: ID of the Moments post being commented on
/// - parentCommentId: parent comment ID
/// - content: comment content
/// - completeBlock: result callback
- (void)addComment:(nonnull NSString *)momentId
parentCommentId:(nullable NSString *)parentCommentId
content:(nonnull NSString *)content
complete:(nullable void (^)(JErrorCode errorCode, JMomentComment * _Nullable comment))completeBlock;
Code Example
// "parentCommentId" may be empty
[JIM.shared.momentManager addComment:@"momentId"
parentCommentId:@"parentCommentId"
content:@"Good picture!"
complete:^(JErrorCode errorCode, JMomentComment * _Nullable comment) {
}];
Add a comment. Replies to another user's comment are also supported.
API Reference
/**
* post a comment
* @param momentId ID of the Moments post being commented on
* @param content comment content
* @param parentCommentId parent comment ID; may be empty
* return MomentComment object
*/
Future<Result<MomentComment>> addMomentComment(String momentId, String content, [String? parentCommentId]) async
Code Example
// "parentCommentId" may be empty
Result<MomentComment> comment = await JuggleIm.instance.addMomentComment('momentId', 'Good picture!', 'parentCommentId');
Add a comment. Replies to another user's comment are also supported.
API Reference
/**
* post a comment
* @param momentId ID of the Moments post being commented on
* @param content comment content
* @param parentCommentId parent comment ID; may be empty
* return Promise<MomentComment> object
*/
addComment(momentId: string, content: string, parentCommentId?: string): Promise<MomentComment>
Code Example
// "parentCommentId" may be empty
import { JuggleIMMoment } from 'juggleim-rnsdk';
const comment = await JuggleIMMoment.addComment('momentId', 'Good picture!', 'parentCommentId');
Add a comment. Replies to another user's comment are also supported.
Parameters
| Name | Type | Required | Default | Description | Version |
|---|---|---|---|---|---|
| params | Object | Yes | - | Comment information | 1.9.6 |
| params.momentId | String | Yes | - | Moment ID | 1.9.6 |
| params.parentCommentId | String | No | - | Replied-to comment ID. It is an empty string when replying to a root comment. | 1.9.6 |
| params.content | Object | Yes | - | Comment content | 1.9.6 |
Callback Parameters
| Property | Type | Description | Version |
|---|---|---|---|
| result | Object | Query result | 1.9.6 |
| result.comment | Object | Comment object. See the Comment | 1.9.6 |
Code Example
// Reply to a comment
let comment = {
momentId: 'momentId',
parentCommentId: '',
content: {
text: 'This is a reply to a top-level comment'
}
};
jim.addComment(comment).then((result) => {
console.log('addComment successfully', result)
});
// Reply to a nested comment
let content = {
text: 'This is a reply to a nested comment'
};
jim.addComment({
momentId: 'momentId',
parentCommentId: 'parentCommentId',
content
}).then((result) => {
console.log('addComment successfully', result)
});