Working with Comments

Post Comment

If you want to post a comment to activity, you can easily do it with following code:

  1. Create comment content:

    1
    2
    GetSocialActivityPostContent *commentContent = [GetSocialActivityPostContent new];
    commentContent.text = @"I know how to kill that boss!";
    
  2. Post comment to activity:

    1
    2
    3
    4
    5
    6
    7
    [GetSocial postComment:commentContent
      toActivityWithId:activityId
               success:^(GetSocialActivityPost *post) {
                   NSLog(@"You comment was successfully posted!");
               } failure:^(NSError *error) {
            NSLog(@"Failed to post a comment, error: %@", error);
        }];
    

You can post images and buttons in the comment content too.

activityId - is a unique identifier of activity, that you want to comment. You can get it from ActivityPost object:

1
NSString *activityId = activityYouWantToComment.activityId;

Note

You can post comments only to activities, for now we do not support nested comments.

List Comments

To get a list of comments to activity:

1
2
3
4
5
6
GetSocialActivitiesQuery *query = [GetSocialActivitiesQuery commentsToPost:activityId];
[GetSocial activitiesWithQuery:query success:^(NSArray<GetSocialActivityPost *> *comments) {
    NSLog(@"Successfully retrieved comments!");
} failure:^(NSError *error) {
    NSLog(@"Failed to get comments, error: %@", error);
}];

GetSocial UI

In GetSocial Activity Feed UI list of activity comments are opened after user clicked on activity post or comments count.


GetSocial Activity Comments View

Open Comments View

You may want to open Comments List directly from code, it can be done with next code:

1
2
GetSocialUIActivityDetailsView *detailsView = [GetSocialUI createActivityDetailsView:activityId];
[detailsView show];

It will show an activity details view with a list of comments. Also, you’ll have a feed view where this activity is posted. If you want to omit feed view in history, use setShowActivityFeedView: method:

1
2
3
GetSocialUIActivityDetailsView *detailsView = [GetSocialUI createActivityDetailsView:activityId];
[detailsView setShowActivityFeedView:NO];
[detailsView show];

Handlers and Window Customizations

You can set ActionButtonHandler and AvatarClickHandler in the same way as for ActivityFeedView. See more.

Give us your feedback! Was this article helpful?

😀 🙁