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
    3
    ActivityPostContent commentContent = new ActivityPostContent.Builder ()
        .WithText ("I know how to kill that boss!")
        .Build ();
    
  2. Post comment to activity:

    1
    2
    3
    4
    5
    6
    7
    GetSocial.PostCommentToActivity (activityId, commentContent,
        post => {
            Debug.Log("Your comment was succesfully posted");
        }, 
        error => {
            Debug.LogWarning("Failed to post a comment, error: " + error.Message);
        });
    

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
string activityId = activityYouWantToComment.Id;

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
7
8
ActivitiesQuery query = ActivitiesQuery.CommentsToPost (activityId);
GetSocial.GetActivities (query, 
    posts => {
        Debug.Log ("Succesfully retrieved comments list!");
    }, 
    error => {
        Debug.LogWarning ("Failed to get comments, error: " + error.Message);
    });

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
GetSocialUi.СreateActivityDetailsView(activityId)
    .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
GetSocialUi.СreateActivityDetailsView(activityId)
    .SetShowActivityFeedView(false)
    .Show();

Listeners and Window Customizations

You can set ActionButtonListener and AvatarClickListener in the same way as for ActivityFeedViewBuilder. See more.

Give us your feedback! Was this article helpful?

😀 🙁