Skip to content

Actions

Create Action

To create an action use CreateBuilder method:

1
var action = GetSocialAction.CreateBuilder(GetSocialActionType.Custom).build();

Add action data using AddActionData(string key, string val) or AddActionData(Dictionary<string, string> map) - second one will add all the keys and values from parameter map. For the default GetSocial actions use one of GetSocialActionKeys constants to guarantee the default behaviour. Also you can pass any custom data you want and handle it on the receiver side.

You can send any of predefined actions that will be handled by the SDK, for example to open Activity Feed with id “funny-stories” use:

1
2
3
var action = ActGetSocialActionion.CreateBuilder(GetSocialActionType.OpenActivity)
        .addActionData(GetSocialActionKeys.OpenActivity.FeedName, "funny-stories")
        .build();

Currently you can attach actions to notifications or activity posts.

Handle Action

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
public bool HandleAction(GetSocialAction action)
{
    switch (action.Type)
    {
        case GetSocialActionType.OpenProfile:
            ShowNewFriend(action.Data[GetSocialActionKeys.OpenProfile.UserId]);
            return true;
        case "try-campaign-mode":
            StartCampaignMode();
            return true;
        default:
            return false;
    }
}

To handle custom actions use:

Tip

If you are not using GetSocial UI, we recommend to handle action by yourself - better user experience would be to react to actions.

GetSocial Actions

  1. Open User Profile.

    GetSocialActionType.OpenProfile is not handled by GetSocial. Parameters:

    • GetSocialActionKeys.OpenProfile.UserId - GetSocial user ID whose profile should be opened.
  2. Open Activity Feed.

    GetSocialActionType.OpenActivity is handled by GetSocial UI. Will open activity feed with provided name, or activity feed post itself or scroll to the certain comment if provided. Parameters:

    • GetSocialActionKeys.OpenActivity.ActivityId - Activity Feed post ID.
    • GetSocialActionKeys.OpenActivity.CommentId - Comment under that activity. Optional.

    or:

    • GetSocialActionKeys.OpenActivity.FeedName - Feed to Open. Use ActivitiesQuery.GlobalFeed to open global feed.
  3. Open Smart Invites.

    GetSocialActionType.OpenInvites is handled by GetSocial UI. Will open Smart Invites screen. Has no required parameters.

  4. Open URL.

    GetSocialActionType.OpenUrl is handled by GetSocial Core. Wil open a system web browser with provided URL. Parameters:

    • GetSocialActionKeys.OpenUrl.Url - URL to open.

Process Action

To process an action by GetSocial, use GetSocial.ProcessAction(GetSocialAction action). It might be useful for custom notification center.

Give us your feedback! Was this article helpful?

😀 🙁