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:

```java tab=”Android(Java)” hl_lines=”2”
ActivityPostContent postContent = ActivityPostContent
.createBuilderWithText(“Hello, this is my first post!”)
.build()

```kotlin tab="Android(Kotlin)" hl_lines="2"
val postContent = ActivityPostContent
    .createBuilderWithText("Hello, this is my first post!")
    .build()

```objective-c tab=”iOS(Objective-C)” hl_lines=”2”
GetSocialActivityPostContent *postContent = [GetSocialActivityPostContent new];
postContent.text = @”Hello, this is my first post!”;

```swift tab="iOS(Swift)" hl_lines="2"
let postContent = GetSocialActivityPostContent()
postContent.text = "Hello, this is my first post!"

```csharp tab=”Unity” hl_lines=”2”
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](/knowledge-base/media-attachment) guide.

!!! tip "Recommended Image Size"
        Recommended image resolution is **1024x768px**. Bigger images are downscaled.

```java tab="Android(Java)" hl_lines="4"
Bitmap activityImage = ...; // Load image here

ActivityPostContent postContent = ActivityPostContent
    .createBuilderwithMediaAttachment(MediaAttachment.image(activityImage))
    .build();

```kotlin tab=”Android(Kotlin)” hl_lines=”4”
val activityImage : Bitmap = … // Load image here

val postContent = ActivityPostContent
.createBuilderWithMediaAttachment(MediaAttachment.image(activityImage))
.build()

```objective-c tab="iOS(Objective-C)" hl_lines="4"
UIImage *postImage = ... ; // Load image here

GetSocialActivityPostContent *postContent = [GetSocialActivityPostContent new];
postContent.mediaAttachment = [GetSocialMediaAttachment image:postImage];

```swift tab=”iOS(Swift)” hl_lines=”4”
let postImage: UIImage = … // Load image here

let postContent = GetSocialActivityPostContent()
postContent.mediaAttachment = GetSocialMediaAttachment.image(postImage)

```csharp tab="Unity" hl_lines="4"
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:

```java tab=”Android(Java)” hl_lines=”10”
// 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();

```kotlin tab="Android(Kotlin)" hl_lines="10"
// Create Action
val actionButton = Action.builder(ActionTypes.OPEN_PROFILE)
    .addActionData(ActionDataKeys.OpenProfile.USER_ID, GetSocial.User.getId())
    .build()

// Create post content with Action Button
val buttonTitle = "Look now!"
val contentWithButton = ActivityPostContent
    .createBuilderWithText("Look at my cool profile!")
    .withButton(buttonTitle, actionButton)
    .build()

```objective-c tab=”iOS(Objective-C)” hl_lines=”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;

```swift tab="iOS(Swift)" hl_lines="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

```csharp tab=”Unity” hl_lines=”9”
// 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](/guides/activity-feed/load-content/#action-buttons) guide.

### Mentions

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

```java tab="Android(Java)" hl_lines="2"
PublicUser user = ...;
String contentText = String.format("Hello, @%s. How are you?", user.getId());

ActivityPostContent postContent = ActivityPostContent
                .createBuilderWithText(contentText)
                .build();

```kotlin tab=”Android(Kotlin)” hl_lines=”2”
val user : PublicUser = …
val contentText = “Hello, @${user.id}. How are you?”

val postContent = ActivityPostContent
.createBuilderWithText(contentText)
.build()

```objective-c tab="iOS(Objective-C)" hl_lines="2"
GetSocialPublicUser user = ...;
NSString *contentText = [NSString stringWithFormat:@"Hello, @%@. How are you?", user.userId];

GetSocialActivityPostContent *postContent = [GetSocialActivityPostContent new];
postContent.text = contentText;

```swift tab=”iOS(Swift)” hl_lines=”2”
let user: GetSocialPublicUser? = …
let contentText = “Hello, @(user.userId). How are you?”

let postContent = GetSocialActivityPostContent()
postContent.text = contentText

```csharp tab="Unity"  hl_lines="2"
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.

```java tab=”Android(Java)” hl_lines=”1”
String contentText = “#get#social with your friends!”;
ActivityPostContent postContent = ActivityPostContent
.createBuilderWithText(contentText)
.build();

```kotlin tab="Android(Kotlin)" hl_lines="1"
val contentText = "#get#social with your friends!"
val postContent = ActivityPostContent
    .createBuilderWithText(contentText)
    .build()

```objective-c tab=”iOS(Objective-C)” hl_lines=”2”
GetSocialActivityPostContent *postContent = [GetSocialActivityPostContent new];
postContent.text = @”Like my #cat photo!”;

```swift tab="iOS(Swift)" hl_lines="2"
let postContent = GetSocialActivityPostContent()
postContent.text = "Like my #cat photo!"

```csharp tab=”Unity” hl_lines=”2”
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](/guides/activity-feed/load-content/#tags) guide.

## Post activity posts

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

```java tab="Android(Java)"
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", "Your activity was successfully posted!");
        }

        @Override
        public void onFailure(GetSocialException e) {
            Log.e("GetSocial", "Failed to post activity, error: " + e.getMessage());
        }
});

```kotlin tab=”Android(Kotlin)”
val feedId = “sample-feed-id”
val postContent : ActivityPostContent = … // Create post content

// Use GetSocial.postActivityToGlobalFeed(…) to post content to a default global feed
GetSocial.postActivityToFeed(feedId, postContent, object: Callback{
override fun onSuccess(activityPost: ActivityPost) {
println(“Your activity was successfully posted!”)
}

1
2
3
override fun onFailure(exception: GetSocialException) {
    println("Failed to post activity, error: ${exception.message}")
}

})
objc tab=”iOS(Objective-C)”
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);
}];
```

```swift tab=”iOS(Swift)”
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)”)
})

```csharp tab="Unity"
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.

    ```java tab=”Android(Java)”
    ActivityPostContent commentContent = ActivityPostContent
    .createBuilderWithText(“I know how to kill that boss !”)
    .build();

    ```kotlin tab="Android(Kotlin)"
    val commentContent = ActivityPostContent
        .createBuilderWithText("I know how to kill that boss !")
        .build()
    

    ```objective-c tab=”iOS(Objective-C)”
    GetSocialActivityPostContent *commentContent = [GetSocialActivityPostContent new];
    commentContent.text = @”I know how to kill that boss!”;

    ```swift tab="iOS(Swift)"
    let commentContent = GetSocialActivityPostContent()
    commentContent.text = "I know how to kill that boss!"
    

    csharp tab="Unity" ActivityPostContent commentContent = new ActivityPostContent.Builder () .WithText ("I know how to kill that boss!") .Build ();

  2. Post comment to activity post or announcement:

    ```java tab=”Android(Java)”
    GetSocial.postCommentToActivity(activityId, commentContent, new Callback() {
    @Override
    public void onSuccess(ActivityPost commentPost) {
    Log.i(“GetSocial”, “Your comment was successfully posted!”);
    }

    1
    2
    3
    4
    @Override
    public void onFailure(GetSocialException e) {
        Log.e("GetSocial", "Failed to post comment, error: " + e.getMessage());
    }
    

    });
    kotlin tab=”Android(Kotlin)”
    GetSocial.postCommentToActivity(activityId, commentContent, object: Callback{
    override fun onSuccess(activityPost: ActivityPost) {
    println(“Your comment was successfully posted!”)
    }

    override fun onFailure(exception: GetSocialException) {
    println(“Failed to post comment, error: ${exception.message}”)
    }
    })
    ```

    ```objective-c tab=”iOS(Objective-C)”
    [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);
    }];

    ```swift tab="iOS(Swift)"
    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)")
    })
    

    ```csharp tab=”Unity”
    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:
    
    ```java tab="Android(Java)"
    String activityId = activityYouWantToComment.getId();
    

    ```kotlin tab=”Android(Kotlin)”
    val activityId = activityYouWantToComment.id

    ```objective-c tab="iOS(Objective-C)"
    NSString *activityId = activityYouWantToComment.activityId;
    

    ```swift tab=”iOS(Swift)”
    let activityId = activityYouWantToComment.activityId

    ```csharp tab="Unity"
    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:

```java tab=”Android(Java)”
boolean isLiked = true;
String activityId = …; // Get activity post, announcement or comment ID you want to like

GetSocial.likeActivity(activityId, isLiked, new Callback() {
@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();
}

1
2
3
4
@Override
public void onFailure(GetSocialException e) {
    Log.e("GetSocial", "Failed to like post: " + e.getMessage());
}

});
kotlin tab=”Android(Kotlin)”
val isLiked = true
val activityId = … // Get activity post, announcement or comment ID you want to like

GetSocial.likeActivity(activityId, isLiked, object : Callback{
override fun onSuccess(activityPost: ActivityPost) {
println(“Activity was successfully liked”)
// You can check if activity is liked by calling
// val isPostLikedByMe = activityPost.isLikedByMe
}

override fun onFailure(exception: GetSocialException) {
println(“Failed to like post, error: ${exception.message}”)
}
})
```

```objective-c tab=”iOS(Objective-C)”
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);
}];

```swift tab="iOS(Swift)"
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)")
})

```csharp tab=”Unity”
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?

😀 🙁