Skip to content

Post on GetSocial Activity Feed

Activity Feed consists of posts and announcements. Announcements are high priority posts that you as a developer can post from the Dashboard.

It is possible to post comments and likes to any activity post or announcement.

The guide below describes what kind of content posts and announcements can contain and how to post activities, announcements, comments, and likes from SDK.

Save time with prebuilt Activity Feed UI

Activity Feed UI Features
Let your users post, comment and like on your Activity Feed with one line of code with prebuilt UI. Check Activity Feed UI guide for more details.

Prerequisite

Activity Post Content

To post an activity, first you have to create an Activity Post Content.

Activity posts, announcements, and comments have the same structure of content. You can mix and match any of the available content types.

We’ll guide you through types of content you can attach. To learn how to load and display Activity Posts on your UI visit this guide.

Text

To create an activity post content with text:

1
2
3
ActivityPostContent postContent = ActivityPostContent
            .createBuilderWithText("Hello, this is my first post!")
            .build()
1
2
GetSocialActivityPostContent *postContent = [GetSocialActivityPostContent new];
postContent.text = @"Hello, this is my first post!";
1
2
let postContent = GetSocialActivityPostContent()
postContent.text = "Hello, this is my first post!"
1
2
3
ActivityPostContent postContent = new ActivityPostContent.Builder()
        .WithText("Hello, this is my first post!")
        .Build();

Media attachment

You can attach images, GIFs and videos to the Activity Post Content. For the full list of supported file formats check the Media Attachments guide.

Recommended Image Size

Recommended image resolution is 1024x768px. Bigger images are downscaled.

1
2
3
4
5
Bitmap activityImage = ...; // Load image here

ActivityPostContent postContent = ActivityPostContent
    .withMediaAttachment(MediaAttachment.image(activityImage))
    .build();
1
2
3
4
UIImage *postImage = ... ; // Load image here

GetSocialActivityPostContent *postContent = [GetSocialActivityPostContent new];
postContent.mediaAttachment = [GetSocialMediaAttachment image:postImage];
1
2
3
4
let postImage: UIImage = ... // Load image here

let postContent = GetSocialActivityPostContent()
postContent.mediaAttachment = GetSocialMediaAttachment.image(postImage)
1
2
3
4
5
Texture2D activityImage = ...; // Load image here

ActivityPostContent postContent = new ActivityPostContent.Builder()
        .WithMediaAttachment(MediaAttachment.Image(activityImage))
        .Build();

Action buttons

Each Action Button has a title to show on the UI and Action that should be executed on click. You can use one of the predefined GetSocial Actions (see for Android, iOS or Unity) or create your custom action.

To add an Action Button to the Activity Post Content:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
// Create Action
Action buttonAction = Action.builder(ActionTypes.OPEN_PROFILE)
                            .addActionData(ActionDataKeys.OpenProfile.USER_ID, GetSocial.User.getId())
                            .build();

// Create post content with Action Button
String buttonTitle = "Look now!";
ActivityPostContent contentWithButton = ActivityPostContent
            .createBuilderWithText("Look at my cool profile!")
            .withButton(buttonTitle, buttonAction)
            .build();
1
2
3
4
5
6
7
8
9
// Create Action
GetSocialActionBuilder *builder = [[GetSocialActionBuilder alloc] initWithType:GetSocialActionOpenProfile];
[builder addActionDataValue:[GetSocialUser userId] forKey:GetSocialActionDataKey_OpenProfile_UserId];
GetSocialAction *action = [builder build];

// Create post content with Action Button
GetSocialActivityPostContent *contentWithButton = [GetSocialActivityPostContent new];
contentWithButton.buttonTitle     = @"Look now!";
contentWithButton.action          = action;
1
2
3
4
5
6
7
8
9
// Create Action
let builder = GetSocialActionBuilder.init(type: GetSocialActionType.openProfile)
builder.addActionDataValue(GetSocialUser.userId(), withKey: GetSocialActionDataKey._OpenProfile_UserId.rawValue)
let action = builder.build()

// Create post content with Action Button
let contentWithButton = GetSocialActivityPostContent()
contentWithButton.buttonTitle = "Look now!"
contentWithButton.action = action
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
// Create Action
var buttonAction = GetSocialAction.CreateBuilder(GetSocialActionType.OpenProfile)
    .AddActionData(GetSocialActionKeys.OpenProfile.UserId, GetSocial.User.Id)
    .Build();

// Create post content with Action Button
var buttonTitle = "Look now!";
ActivityPostContent postContent = new ActivityPostContent.Builder()
    .WithButton(buttonTitle, buttonAction)
    .Build();

To learn how to display and handle clicks on the Action Buttons visit Load Activity Feed Content guide.

Mentions

To mention user in the Activity Feed post insert @12345678, where 12345678 is the GetSocial user id you want to mention.

1
2
3
4
5
6
PublicUser user = ...;
String contentText = String.format("Hello, @%s. How are you?", user.getId());

ActivityPostContent postContent = ActivityPostContent
                .createBuilderWithText(contentText)
                .build();
1
2
3
4
5
GetSocialPublicUser user = ...;
NSString *contentText = [NSString stringWithFormat:@"Hello, @%@. How are you?", user.userId];

GetSocialActivityPostContent *postContent = [GetSocialActivityPostContent new];
postContent.text = contentText;
1
2
3
4
5
let user: GetSocialPublicUser? = ...
let contentText = "Hello, @\(user.userId). How are you?"

let postContent = GetSocialActivityPostContent()
postContent.text = contentText
1
2
3
4
5
6
PublicUser user = ...;
string contentText = string.Format("Hello, @{1}. How are you?", user.Id);

ActivityPostContent postContent = ActivityPostContent.CreateBuilder()
                .WithText(contentText)
                .Build();

To mention the application use "@app" in the post text. When the app is mentioned, you will receive a notification about the mention on the GetSocial Dashboard.

On the backend, when activity is posted, @id is replaced with the display name of the user or app name.

To learn how to display and handle clicks on the mentions visit Load Activity Feed Content guide.

Tags

To post activity with tag, just insert #mytag - where mytag is a tag you want to post. Tags may go one by one without spaces.

Tag Requirements

Tag should contain at least one symbol, consist of letters, numbers and _, and be not longer than 80 symbols. Otherwise, it won’t be treated as tag on the backend side.

1
2
3
4
String contentText = "#get#social with your friends!";
ActivityPostContent postContent = ActivityPostContent
                .createBuilderWithText(contentText)
                .build();
1
2
GetSocialActivityPostContent *postContent = [GetSocialActivityPostContent new];
postContent.text = @"Like my #cat photo!";
1
2
let postContent = GetSocialActivityPostContent()
postContent.text = "Like my #cat photo!"
1
2
3
ActivityPostContent postContent = ActivityPostContent.CreateBuilder()
                .WithText("Like my #cat photo!")
                .Build();

To learn how to display and handle clicks on the tags visit Load Activity Feed Content guide.

Post activity posts

To post an activity post, you have to pass feed ID along with post content:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
String feedId = "sample-feed-id";
ActivityPostContent postContent = ...; // Create post content

// Use GetSocial.postActivityToGlobalFeed(...) to post content to a default global feed
GetSocial.postActivityToFeed(feedId, postContent, new Callback<ActivityPost>() {
        @Override
        public void onSuccess(ActivityPost activityPost) {
            Log.i("GetSocial", "You activity was successfully posted!");
        }

        @Override
        public void onFailure(GetSocialException e) {
            Log.e("GetSocial", "Posting failed, error: " + e.getMessage());
        }
});
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
NSString *feedId = @"sample-feed-id";
GetSocialActivityPostContent *content = ...; // Create post content

// Use [GetSocial postActivityToGlobalFeed: content success: ... failure: ...] to post content to a default global feed
[GetSocial postActivity:content toFeed:feedId
                               success:^(GetSocialActivityPost *post) {
                                    NSLog(@"Successfully posted an activity.");
                               } failure:^(NSError *error) {
                NSLog(@"Failed to post an activity, error: %@", error);
            }];
1
2
3
4
5
6
7
8
9
let feedId = "sample-feed-id"
let content = ... // Create post content

// Use GetSocial.postActivity(toGlobalFeed: content, success: ... , failure: ...)  to post content to a default global feed
GetSocial.postActivity(content, toFeed: feedId, success: { post in
        print("Successfully posted an activity.")
    }, failure: { error in
        print("Failed to post an activity, error: \(error)")
    })
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
var feedId = "sample-feed-id";
var content = ...; // Create post content

// Use GetSocial.PostActivityToGlobalFeed(...) to post content to a default global feed
GetSocial.PostActivityToFeed (feedId, content,
        post => {
            Debug.Log("Your activity was successfully posted!");
        },
        error => {
            Debug.LogWarning("Failed to post activity, error: " + error.Message);
        });

Post announcements

Announcement is a special type of posts in Activity Feed that can be posted only from the Dashboard. Announcements are shown only during the period they are posted for.

To post an announcement:

  1. Login to GetSocial Dashboard.

  2. Go to Activity Feeds section.

  3. Switch to Announcements tab.

    GetSocial Dashboard

  4. Press New announcement button.

  5. Fill announcement content, set a time interval when it should be available on SDK and press Post.

    GetSocial Dashboard - Post Announcement

    You can also change a feed or post an announcement to all existing feeds.

Post сomments

To post a comment to Activity Feed:

  1. Create comment content. Comment supports the same content types as posts and announcements.

    1
    2
    3
    ActivityPostContent commentContent = ActivityPostContent
            .createBuilderWithText("I know how to kill that boss !")
            .build();
    
    1
    2
    GetSocialActivityPostContent *commentContent = [GetSocialActivityPostContent new];
    commentContent.text = @"I know how to kill that boss!";
    
    1
    2
    let commentContent = GetSocialActivityPostContent()
    commentContent.text = "I know how to kill that boss!"
    
    1
    2
    3
    ActivityPostContent commentContent = new ActivityPostContent.Builder ()
        .WithText ("I know how to kill that boss!")
        .Build ();
    
  2. Post comment to activity post or announcement:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    GetSocial.postCommentToActivity(activityId, commentContent, new Callback<ActivityPost>() {
        @Override
        public void onSuccess(ActivityPost commentPost) {
            Log.i("GetSocial", "You comment was successfully posted!");
        }
    
        @Override
        public void onFailure(GetSocialException e) {
            Log.e("GetSocial", "Posting failed: " + e.getMessage());
        }
    });
    
    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);
            }];
    
    1
    2
    3
    4
    5
    GetSocial.postComment(commentContent, toActivityWithId: activityId, success: { post in
        print("You comment was successfully posted!")
    }, failure: { error in
        print("Failed to post a comment, error: \(error)")
    })
    
    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);
        });
    

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

    1
    String activityId = activityYouWantToComment.getId();
    
    1
    NSString *activityId = activityYouWantToComment.activityId;
    
    1
    let activityId = activityYouWantToComment.activityId
    
    1
    string activityId = activityYouWantToComment.Id;
    

    Nested Comments Are Not Supported

    We do not support nested comments. You can post comments only to posts and announcements.

Like activities

To like or dislike activity post, announcement or comment:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
boolean isLiked = true;
String activityId = ...; // Get activity post, announcement or comment ID you want to like

GetSocial.likeActivity(activityId, isLiked, new Callback<ActivityPost>() {
    @Override
    public void onSuccess(ActivityPost activityPost) {
        Log.i("GetSocial", "Activity was successfully liked");
        // You can check if activity is liked by calling
        // boolean isPostLikedByMe = activityPost.isLikedByMe();
    }

    @Override
    public void onFailure(GetSocialException e) {
        Log.e("GetSocial", "Failed to like post: " + e.getMessage());
    }
});
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
BOOL isLiked = YES;
NSString *activityId = ...; // Get activity post, announcement or comment ID you want to like

[GetSocial likeActivityWithId:activityId
                isLiked:isLiked
                success:^(GetSocialActivityPost *post) {
                    NSLog(@"Successfully like an activity");
                    // You can check if activity is liked by calling
                    // BOOL isLiked = post.isLikedByMe;
                } failure:^(NSError *error) {
                    NSLog(@"Failed to like an activity, error: %@", error);
                }];
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
let isLiked = true
let activityId = ...; // Get activity post, announcement or comment ID you want to like

GetSocial.likeActivity(withId: activityId, isLiked: isLiked, success: { post in
    print("Successfully like an activity")
    // You can check if activity is liked by calling
    // let isLiked = post.isLikedByMe;
}, failure: { error in
    print("Failed to like an activity, error: \(error)")
})
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
bool isLiked = true;
String activityId = ...; // Get activity post, announcement or comment ID you want to like

GetSocial.LikeActivity (activityId, isLiked, 
    post => {
        Debug.Log("Activity was successfully liked");
        // You can check if activity is liked by calling
        // bool isLiked = post.IsLikedByMe;
    }, 
    error => {
        Debug.LogWarning("Failed to like an activity, error: " + error.Message);
    });

If you want to unlike activity, pass false as parameter isLiked.

We handle data consistency, so if you’re trying to like already liked activity, or dislike not liked activity, an operation invokes successful callback without any changes.

Next steps

Give us your feedback! Was this article helpful?

😀 🙁