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
val activity = ActivityContent.createWithText("Hello, this is my first post!")
1
2
let activityContent = ActivityContent()
activityContent.text = "Hello, this is my first post!"
1
2
var activityContent = new ActivityContent();
activityContent.Text = "Hello, this is my first post!";
1
2
var activityContent = ActivityContent();
activityContent.text = 'Hello, this is my first post!';
1
2
const activityContent = new ActivityContent();
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.

1
2
3
4
5
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"))
1
2
3
4
5
6
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"))
1
2
3
4
5
6
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"));
1
2
3
4
5
6
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'));
1
2
3
4
5
6
const base64EncodedImage = ...; // Load image here
const activityContent = new ActivityContent();
activityContent.attachments.add(MediaAttachment.withBase64Image(base64EncodedImage));

// or you can add more attachments
activityContent.attachments.add(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:

1
2
3
4
5
6
7
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)
1
2
3
4
5
6
7
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
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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;
1
2
3
4
5
6
7
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;
1
2
3
4
5
6
7
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;

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
val user : User = ...
val contentText = "Hello, @${user.id}. How are you?"

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

let activityContent = ActivityContent()
activityContent.text = contentText
1
2
3
4
User user = ...;
var contentText = String.Format("Hello, {0}. How are you?", user.Id);
var activityContent = new ActivityContent();
activityContent.Text = contentText;
1
2
3
4
5
User user = ...;
var userId = user.userId;
var contentText = 'Hello, @$userId. How are you?';
var activityContent = ActivityContent();
activityContent.text = contentText;
1
2
3
4
5
const user = ...;
const userId = user.userId;
const contentText = 'Hello, @' + userId + '. How are you?';
const activityContent = new ActivityContent();
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.

1
2
3
val contentText = "#get#social with your friends!"

val postContent = ActivityPostContent.createWithText(contentText)
1
2
3
let contentText = "#get#social with your friends!"
let activityContent = ActivityContent()
activityContent.text = contentText
1
2
3
var contentText = "#get#social with your friends";
var activityContent = new ActivityContent();
activityContent.Text = contentText;
1
2
3
var contentText = '#get#social with your friends!';
var activityContent = ActivityContent();
activityContent.text = contentText;
1
2
3
const contentText = '#get#social with your friends!';
const activityContent = new ActivityContent();
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.

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

Post activity

To post an activity:

1
2
3
4
5
6
7
8
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")
})
1
2
3
4
5
6
7
8
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)")
})
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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);
    });
1
2
3
4
5
6
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'));
1
2
3
4
5
6
7
8
9
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);
    });

Post to Topic Feed

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

1
2
3
4
5
6
7
8
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")
})
1
2
3
4
5
6
7
8
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)")
})
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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);
    });
1
2
3
4
5
6
ActivityContent activityContent = ...; // Create post
var target = PostActivityTarget.topic('cats');

Communities.postActivity(activityContent, target)
    .then((result) => print('Posted activity: $result'))
    .catchError((error) => print('Failed to post activity, error: $error'));
1
2
3
4
5
6
7
8
9
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);
    });

Post to Group Feed

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

1
2
3
4
5
6
7
8
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")
})
1
2
3
4
5
6
7
8
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)")
})
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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);
    });
1
2
3
4
5
6
ActivityContent activityContent = ...; // Create post
var target = PostActivityTarget.group('clan_x');

Communities.postActivity(activityContent, target)
    .then((result) => print('Posted activity: $result'))
    .catchError((error) => print('Failed to post activity, error: $error'));
1
2
3
4
5
6
7
8
9
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);
    });

Post to User Feed

To post to a user, pass a user ID as post target, e.g. to post into user 1234567890:

1
2
3
4
5
6
7
8
val activity: ActivityContent = ... // Create post
val target: PostActivityTarget = PostActivityTarget.user(1234567890)

Communities.postActivity(activity, target, { result: GetSocialActivity ->
    Log.d("Communities", "Posted activity: $result")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to post activity: $error")
})
1
2
3
4
5
6
7
8
let activityContent = ... // Create post
let target: PostActivityTarget = PostActivityTarget.user(1234567890)

Communities.postActivity(activityContent, target: target, success: { activity in
    print("Posted activity: \(activity)")
}, failure: { error in
    print("Failed to post activity: \(error)")
})
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
ActivityContent activityContent = ... // Create post
var target = PostActivityTarget.User(1234567890);

Communities.PostActivity(activityContent, target,
    (activity) => {
        Debug.Log("Posted activity: " + activity);
    },
    (error) => {
        Debug.Log("Failed to post activity, error: " + error);
    });
1
2
3
4
5
6
ActivityContent activityContent = ...; // Create post
var target = PostActivityTarget.user(1234567890);

Communities.postActivity(activityContent, target)
    .then((result) => print('Posted activity: $result'))
    .catchError((error) => print('Failed to post activity, error: $error'));
1
2
3
4
5
6
7
8
9
const activityContent = ...; // Create post
const target = PostActivityTarget.user(1234567890);

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 post target, e.g. to post comment to activity with id 42:

1
2
3
4
5
6
7
8
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")
})
1
2
3
4
5
6
7
8
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)")
})
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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);
    });
1
2
3
4
5
6
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'));
1
2
3
4
5
6
7
8
9
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);
    });

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

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

Nested Comments Are Not Supported

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

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 reactions to the posts and comments. Currently only a single reaction is supported per activity, so user can not both like and love the same post. If you call addReaction for the post you already had reacted to before, the previous reaction will be overridden.

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

To remove reaction, use symmetric method removeReaction:

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

Next steps

Give us your feedback! Was this article helpful?

😀 🙁