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 comment and react 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.

Limitations

Activities and comments have some limitations to prevent abuse.
Posting content exceeding these limits will fail with an error.

Max Size
Content 512KB
Properties (keys or values) 1KB each
Labels 1KB each
Poll Options 8KB each

Take in mind that special chars can take 2 to 4 bytes. Emojis and other Unicode chars will count as 4 bytes.

Text

To create an activity post content with text:

val activity = ActivityContent.createWithText("Hello, this is my first post!")
let activityContent = ActivityContent()
activityContent.text = "Hello, this is my first post!"
var activityContent = new ActivityContent();
activityContent.Text = "Hello, this is my first post!";
var activityContent = ActivityContent();
activityContent.text = 'Hello, this is my first post!';
const activityContent = new ActivityContent();
activityContent.text = 'Hello, this is my first post!';
const activityContent = new GetSocialSDK.ActivityContent({
    text: 'Hello, this is my first post!'
});

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.

val bitmap: Bitmap = ... // Load image here
val activity = ActivityContent.createWithAttachment(MediaAttachment.image(bitmap))

// or you can add more attachments
activity.addAttachment(MediaAttachment.imageUrl("https://some-domain.my/image.png"))
let image: UIImage = ... // Load image here
let activityContent = ActivityContent()
activityContent.appendMediaAttachment(MediaAttachment.image(image))

// or you can add more attachments
activityContent.appendMediaAttachment(MediaAttachment.imageUrl("https://some-domain.my/image.png"))
Texture2D image = ...; // Load image here
var activityContent = new ActivityContent();
activityContent.AddMediaAttachment(MediaAttachment.WithImage(image));

// or you can add more attachments
activityContent.AddMediaAttachment(MediaAttachment.WithImageUrl("https://some-domain.my/image.png"));
var base64EncodedImage = ...; // Load image here
var activityContent = ActivityContent();
activityContent.attachments.add(MediaAttachment.withBase64Image(base64EncodedImage));

// or you can add more attachments
activityContent.attachments.add(MediaAttachment.withImageUrl('https://some-domain.my/image.png'));
const base64EncodedImage = ...; // Load image here
const activityContent = new ActivityContent();
activityContent.attachments.push(MediaAttachment.withBase64Image(base64EncodedImage));

// or you can add more attachments
activityContent.attachments.push(MediaAttachment.withImageUrl('https://some-domain.my/image.png'));
const base64EncodedImage = '...'; // Load image here
const activityContent = new GetSocialSDK.ActivityContent({
    attachments: [
        GetSocialSDK.MediaAttachment.withBase64Image(base64EncodedImage)
    ]
});

// or you can add more attachments
activityContent.attachments.push(GetSocialSDK.MediaAttachment.withImageUrl('https://some-domain.my/image.png'));

When multiple attachments are added, they will appear in the same order in the resulting activity.
On GetSocial UI currently only the first attachment is displayed.

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:

val action = Action.create(ActionTypes.OPEN_PROFILE, mapOf(ActionDataKeys.OpenProfile.USER_ID to GetSocial.getCurrentUser()!!.id))

val buttonTitle = "Look now!"
val button = ActivityButton.create(buttonTitle, action)
val contentWithButton = ActivityContent
                .createWithText("Look at my cool profile!")
                .withButton(button)
let action = Action.create(type: ActionType.openProfile, data: [ActionDataKey.openProfile_UserId: GetSocial.currentUser()!.userId])
let buttonTitle = "Look now!"
let button = ActivityButton.create(title: buttonTitle, action: action)

let activityContent = ActivityContent()
activityContent.text = "Look at my cool profile!"
activityContent.button = button
var action = GetSocialAction.Create(GetSocialActionType.OpenProfile, new Dictionary<string, string>()
{
    { GetSocialActionKeys.OpenProfile.UserId, GetSocial.GetCurrentUser().Id }
});
var buttonTitle = "Look now!";
var button = ActivityButton.Create(buttonTitle, action);

var activityContent = new ActivityContent();
activityContent.Text = "Look at my cool profile!";
activityContent.Button = button;
var action = GetSocialAction('custom_action', { 'action_key': 'action_value' });
var buttonTitle = 'Look now!';
var button = ActivityButton(buttonTitle, action);

var activityContent = ActivityContent();
activityContent.text = 'Look at my cool profile!';
activityContent.activityButton = button;
const action = Action('custom_action', { 'action_key': 'action_value' });
const buttonTitle = 'Look now!';
const button = ActivityButton(buttonTitle, action);

const activityContent = new ActivityContent();
activityContent.text = 'Look at my cool profile!';
activityContent.activityButton = button;
const action = GetSocialSDK.Action.create('custom_action', { 'action_key': 'action_value' });
const buttonTitle = 'Look now!';
const button = GetSocialSDK.ActivityButton.create(buttonTitle, action);

const activityContent = new GetSocialSDK.ActivityContent({
    text: 'Look at my cool profile!',
    button
});

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.

val user : User = ...
val contentText = "Hello, @${user.id}. How are you?"

val postContent = ActivityPostContent.createWithText(contentText)
let user: User = ...
let contentText = "Hello, @\(user.userId). How are you?"

let activityContent = ActivityContent()
activityContent.text = contentText
User user = ...;
var contentText = String.Format("Hello, {0}. How are you?", user.Id);
var activityContent = new ActivityContent();
activityContent.Text = contentText;
User user = ...;
var userId = user.userId;
var contentText = 'Hello, @$userId. How are you?';
var activityContent = ActivityContent();
activityContent.text = contentText;
const user = ...;
const userId = user.userId;
const contentText = 'Hello, @' + userId + '. How are you?';
const activityContent = new ActivityContent();
activityContent.text = contentText;
const user = ...;
const userId = user.userId;
const contentText = 'Hello, @' + userId + '. How are you?';
const activityContent = new ActivityContent({
    text: contentText
});

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.

val contentText = "#get#social with your friends!"

val postContent = ActivityPostContent.createWithText(contentText)
let contentText = "#get#social with your friends!"
let activityContent = ActivityContent()
activityContent.text = contentText
var contentText = "#get#social with your friends";
var activityContent = new ActivityContent();
activityContent.Text = contentText;
var contentText = '#get#social with your friends!';
var activityContent = ActivityContent();
activityContent.text = contentText;
const contentText = '#get#social with your friends!';
const activityContent = new ActivityContent();
activityContent.text = contentText;
const contentText = '#get#social with your friends!';
const activityContent = new ActivityContent({
    text: contentText
});

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

Properties

You can add custom key-value properties to any post.

val contentWithButton = ActivityContent
                .createWithText("Look at my cool profile!")
                .addProperty("postedAt", "level4")
let activityContent = ActivityContent()
activityContent.text = "Look at my cool profile!"
activityContent.properties = ["postedAt": "level4"]
var contentText = "#get#social with your friends";
var activityContent = new ActivityContent();
activityContent.AddProperty("PostedAt", "level4");
var activityContent = ActivityContent();
activityContent.text = 'Look at my cool profile!';
activityContent.properties = { 'PostedAt': 'level4' };
const activityContent = new ActivityContent();
activityContent.text = 'Look at my cool profile!';
activityContent.properties = { 'PostedAt': 'level4' };
const activityContent = new GetSocialSDK.ActivityContent({
    text: 'Look at my cool profile!',
    properties: { postedAt: 'level4' }
});

Post activity

To post an activity:

val activity: ActivityContent = ... // Create post
val target: PostActivityTarget = ... // Choose target

Communities.postActivity(activity, target, { result: GetSocialActivity ->
    Log.d("Communities", "Posted activity: $result")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to post activity: $error")
})
let activityContent = ... // Create post
let target: PostActivityTarget = // Create target

Communities.postActivity(activityContent, target: target, success: { activity in
    print("Posted activity: \(activity)")
}, failure: { error in
    print("Failed to post activity: \(error)")
})
ActivityContent activityContent = ... // Create post
PostActivityTarget target = ... // Create target

Communities.PostActivity(activityContent, target,
    (activity) => {
        Debug.Log("Posted activity: " + activity);
    },
    (error) => {
        Debug.Log("Failed to post activity, error: " + error);
    });
ActivityContent activityContent = ...; // Create post
PostActivityTarget target = ...; // Create target

Communities.postActivity(activityContent, target)
    .then((result) => print('Posted activity: $result'))
    .catchError((error) => print('Failed to post activity, error: $error'));
const activityContent = ...; // Create post
const target = ...; // Create target

Communities.postActivity(activityContent, target)
    .then((result) => {
        console.log('Posted activity: ' + result);
    }, (error) => {
        console.log('Failed to post activity, error: ' + error.message);
    });
const activityContent = ...; // Create post
const target = ...; // Create target

GetSocialSDK.Communities.postActivity(activityContent, target)
    .then((result) => {
        console.log('Posted activity: ', result);
    }, (error) => {
        console.log('Failed to post activity, error: ', error);
    });

Post to Topic Feed

To post to a topic, pass a topic ID as post target, e.g. to post into topic cats:

val activity: ActivityContent = ... // Create post
val target: PostActivityTarget = PostActivityTarget.topic("cats")

Communities.postActivity(activity, target, { result: GetSocialActivity ->
    Log.d("Communities", "Posted activity: $result")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to post activity: $error")
})
let activityContent = ... // Create post
let target: PostActivityTarget = PostActivityTarget.topic("cats")

Communities.postActivity(activityContent, target: target, success: { activity in
    print("Posted activity: \(activity)")
}, failure: { error in
    print("Failed to post activity: \(error)")
})
ActivityContent activityContent = ... // Create post
var target = PostActivityTarget.Topic("cats");

Communities.PostActivity(activityContent, target,
    (activity) => {
        Debug.Log("Posted activity: " + activity);
    },
    (error) => {
        Debug.Log("Failed to post activity, error: " + error);
    });
ActivityContent activityContent = ...; // Create post
PostActivityTarget target = PostActivityTarget.topic('cats');

Communities.postActivity(activityContent, target)
    .then((result) => print('Posted activity: $result'))
    .catchError((error) => print('Failed to post activity, error: $error'));
const activityContent = ...; // Create post
const target = PostActivityTarget.topic('cats');

Communities.postActivity(activityContent, target)
    .then((result) => {
        ('Posted activity: ' + result);
    }, (error) => {
        console.log('Failed to post activity, error: ' + error);
    });
const activityContent = ...; // Create post
const target = GetSocialSDK.PostActivityTarget.topic('cats');

GetSocialSDK.Communities.postActivity(activityContent, target)
    .then((result) => {
        ('Posted activity: ', result);
    }, (error) => {
        console.log('Failed to post activity, error: ', error);
    });

Post to Group Feed

To post to a group, pass a group ID as post target, e.g. to post into group clan_x:

val activity: ActivityContent = ... // Create post
val target: PostActivityTarget = PostActivityTarget.group("clan_x")

Communities.postActivity(activity, target, { result: GetSocialActivity ->
    Log.d("Communities", "Posted activity: $result")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to post activity: $error")
})
let activityContent = ... // Create post
let target: PostActivityTarget = PostActivityTarget.group("clan_x")

Communities.postActivity(activityContent, target: target, success: { activity in
    print("Posted activity: \(activity)")
}, failure: { error in
    print("Failed to post activity: \(error)")
})
ActivityContent activityContent = ... // Create post
var target = PostActivityTarget.Group("clan_x");

Communities.PostActivity(activityContent, target,
    (activity) => {
        Debug.Log("Posted activity: " + activity);
    },
    (error) => {
        Debug.Log("Failed to post activity, error: " + error);
    });
ActivityContent activityContent = ...; // Create post
PostActivityTarget target = PostActivityTarget.topic('clan_x');

Communities.postActivity(activityContent, target)
    .then((result) => print('Posted activity: $result'))
    .catchError((error) => print('Failed to post activity, error: $error'));
const activityContent = ...; // Create post
const target = PostActivityTarget.group('clan_x');

Communities.postActivity(activityContent, target)
    .then((result) => {
        ('Posted activity: ' + result);
    }, (error) => {
        console.log('Failed to post activity, error: ' + error);
    });
const activityContent = ...; // Create post
const target = GetSocialSDK.PostActivityTarget.group('clan_x');

GetSocialSDK.Communities.postActivity(activityContent, target)
    .then((result) => {
        ('Posted activity: ', result);
    }, (error) => {
        console.log('Failed to post activity, error: ', error);
    });

Post to User Feed

To post to the current user’s feed, use the timeline method:

val activity: ActivityContent = ... // Create post
val target: PostActivityTarget = PostActivityTarget.timeline()

Communities.postActivity(activity, target, { result: GetSocialActivity ->
    Log.d("Communities", "Posted activity: $result")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to post activity: $error")
})
let activityContent = ... // Create post
let target: PostActivityTarget = PostActivityTarget.timeline()

Communities.postActivity(activityContent, target: target, success: { activity in
    print("Posted activity: \(activity)")
}, failure: { error in
    print("Failed to post activity: \(error)")
})
ActivityContent activityContent = ... // Create post
var target = PostActivityTarget.Timeline();

Communities.PostActivity(activityContent, target,
    (activity) => {
        Debug.Log("Posted activity: " + activity);
    },
    (error) => {
        Debug.Log("Failed to post activity, error: " + error);
    });
ActivityContent activityContent = ...; // Create post
var target = PostActivityTarget.timeline();

Communities.postActivity(activityContent, target)
    .then((result) => print('Posted activity: $result'))
    .catchError((error) => print('Failed to post activity, error: $error'));
const activityContent = ...; // Create post
const target = PostActivityTarget.timeline();

Communities.postActivity(activityContent, target)
    .then((result) => {
        ('Posted activity: ', result);
    }, (error) => {
        console.log('Failed to post activity, error: ' + error);
    });
const activityContent = ...; // Create post
const target = GetSocialSDK.PostActivityTarget.timeline();

GetSocialSDK.Communities.postActivity(activityContent, target)
    .then((result) => {
        ('Posted activity: ', result);
    }, (error) => {
        console.log('Failed to post activity, error: ', error);
    });

Post Comment

To post a comment, pass an activity ID as target.
The target can be activity ID of a post, announcement or comments.

Posting a comment using an activity ID of a comment allows you to created nested comments.
There is no limit on how many levels you can use, it’s up to your implementation.

val activity: ActivityContent = ... // Create post
val target: PostActivityTarget = PostActivityTarget.comment("42")

Communities.postActivity(activity, target, { result: GetSocialActivity ->
    Log.d("Communities", "Posted comment: $result")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to post activity: $error")
})
let activityContent = ... // Create post
let target: PostActivityTarget = PostActivityTarget.comment(to: "42")

Communities.postActivity(activityContent, target: target, success: { activity in
    print("Posted comment: \(activity)")
}, failure: { error in
    print("Failed to post comment: \(error)")
})
ActivityContent activityContent = ... // Create comment
var target = PostActivityTarget.Comment("42");

Communities.PostActivity(activityContent, target,
    (activity) => {
        Debug.Log("Posted comment: " + activity);
    },
    (error) => {
        Debug.Log("Failed to post comment, error: " + error);
    });
ActivityContent activityContent = ...; // Create post
var target = PostActivityTarget.comment('42');

Communities.postActivity(activityContent, target)
    .then((result) => print('Posted comment: $result'))
    .catchError((error) => print('Failed to post comment, error: $error'));
const activityContent = ...; // Create post
const target = PostActivityTarget.comment('42');

Communities.postActivity(activityContent, target)
    .then((result) => {
        console.log('Posted comment: ' + result);
    }, (error) => {
        console.log('Failed to post comment, error: ' + error.message);
    });
const activityContent = ...; // Create post
const target = GetSocialSDK.PostActivityTarget.comment('42');

GetSocialSDK.Communities.postActivity(activityContent, target)
    .then((result) => {
        console.log('Posted comment: ', result);
    }, (error) => {
        console.log('Failed to post comment, error: ', error);
    });

activityId - is a unique identifier of activity post, announcement or even other comment. You can get it from Activity object:

val activityId = activityYouWantToComment.id
let activityId = activityYouWantToComment.activityId
var activityId = activityYouWantToComment.Id;
var activityId = activityYouWantToComment.id;
const activityId = activityYouWantToComment.id;
const activityId = activityYouWantToComment.id;

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 Communities 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.

Reactions

You can add multiple reactions to the posts and comments. If you add a reaction, the previously added reactions will be kept. If you want to remove the earlier added ones, call setReaction method.

Communities.addReaction(Reactions.HAHA, activityId, {
    Log.d("Communities", "Reacted to activity")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to react to activity: $error")
})
Communities.addReaction(Reactions.haha, activityId: activityId, success: {
    print("Reaction added")
}, failure: { error in
    print("Failed to add reaction: \(error)")
})
Communities.AddReaction(Reactions.Haha, activityId,
    () => {
        Debug.Log("Reaction added");
    },
    (error) => {
        Debug.Log("Failed to add reaction, error: " + error);
    });
Communities.addReaction('haha', activityId)
    .then((result) => print('Reaction added'))
    .catchError((error) => print('Failed to add reaction, error: $error'));
Communities.addReaction('haha', activityId)
    .then((result) => {
        console.log('Reaction added');
    }, (error) => {
        console.log('Failed to add reaction, error: ' + error.message);
    });
GetSocialSDK.Communities.addReaction('haha', activityId)
    .then((result) => {
        console.log('Reaction added');
    }, (error) => {
        console.log('Failed to add reaction, error: ', error);
    });

To remove reaction, use symmetric method removeReaction:

Communities.removeReaction(Reactions.HAHA, activityId, {
    Log.d("Communities", "Remove reaction from activity")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to remove reaction from activity: $error")
})
Communities.removeReaction(Reactions.haha, activityId: activityId, success: {
    print("Reaction removed")
}, failure: { error in
    print("Failed to remove reaction: \(error)")
})
Communities.RemoveReaction(Reactions.Haha, activityId,
    () => {
        Debug.Log("Reaction removed");
    },
    (error) => {
        Debug.Log("Failed to remove reaction, error: " + error);
    });
Communities.removeReaction('haha', activityId)
    .then((result) => print('Reaction removed'))
    .catchError((error) => print('Failed to remove reaction, error: $error'));
Communities.removeReaction('haha', activityId)
    .then((result) => {
        console.log('Reaction removed');
    }, (error) => {
        console.log('Failed to remove reaction, error: ' + error.message);
    });
GetSocialSDK.Communities.removeReaction('haha', activityId)
    .then((result) => {
        console.log('Reaction removed');
    }, (error) => {
        console.log('Failed to remove reaction, error: ', error);
    });

Bookmarks

You can bookmark post and fetch all of them togheter.

Communities.bookmark(activityId, {
    Log.d("Communities", "Bookmark added")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to bookmark: $error")
})
Communities.bookmark(activityId: activityId, success: {
    print("Bookmark added")
}, failure: { error in
    print("Failed to bookmark: \(error)")
})
Communities.bookmark(activityId)
    .then((result) => print('Bookmark added'))
    .catchError((error) => print('Failed to bookmark, error: $error'));
Communities.bookmark(activityId)
    .then(() => console.log('Bookmark added'))
    .catch((error) => console.error('Failed to bookmark, error: ', error));
GetSocialSDK.Communities.bookmark(activityId)
    .then(() => console.log('Bookmark added'))
    .catch((error) => console.error('Failed to bookmark, error: ', error));

To fetch bookmarks you can load activities with this query:

Note

The bookmark filter can’t be combined with any other of the filters in ActivitiesQuery.

val query = ActivitiesQuery.bookmarkedActivities()
let query = ActivitiesQuery.bookmarkedActivities()
ActivitiesQuery query = ActivitiesQuery.bookmarkedActivities();
const query = ActivitiesQuery.bookmarkedActivities();
const query = GetSocialSDK.ActivitiesQuery.bookmarkedActivities();

To remove a bookmark, use symmetric method removeBookmark:

Communities.removeBookmark(activityId, {
    Log.d("Communities", "Bookmark removed")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to remove Bookmark: $error")
})
Communities.removeBookmark(activityId: activityId, success: {
    print("Bookmark removed")
}, failure: { error in
    print("Failed to remove Bookmark: \(error)")
})
Communities.removeBookmark(activityId)
    .then((result) => print('Bookmark removed'))
    .catchError((error) => print('Failed to remove Bookmark, error: $error'));
Communities.removeBookmark(activityId)
    .then(() => console.log('Bookmark removed'))
    .catch((error) => console.error('Failed to remove bookmark, error: ', error));
GetSocialSDK.Communities.removeBookmark(activityId)
    .then(() => console.log('Bookmark removed'))
    .catch((error) => console.error('Failed to remove bookmark, error: ', error));

Next steps

Give us your feedback! Was this article helpful?

😀 🙁