Skip to content

Actions

Create Action

To create an action use builder method:

1
Action action = Action.builder("my-custom-action").build();

Add action data using addActionData(String key, String val) or addActionData(Map<String, String> map) - second one will add all the keys and values from parameter map. For the default GetSocial actions use one of ActionDataKeys 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
Action action = Action.builder(ActionTypes.OPEN_ACTIVITY)
        .addActionData(ActionDataKeys.OpenActivity.FEED_NAME, "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
15
boolean handleAction(Action action) {
    switch (action.getType()) {
        case ActionTypes.OPEN_PROFILE: // handle GetSocial action
            showUserProfile(action.getData().get(ActionDataKeys.OpenProfile.USER_ID));
            return true;

        case "try-campaign-mode": // handle custom action
            startCampaignMode();
            return true;

        default:
            // Other actions are handled by GetSocial.
            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

GetSocial SDK provides a list of predefined actions and processAction(...) method to process them. We use it internally in GetSocial UI. For you it may be helpful when building your custom UI.

1
GetSocial.processAction(Action action);

Handled by GetSocial Core

  • ActionTypes.OPEN_URL: Wil open a system web browser with provided URL. Required parameters:
    • ActionDataKeys.OpenUrl.URL - URL to open.
  • ActionTypes.ADD_FRIEND: Add user the the list of friends on Social Graph. Parameters:
    • ActionDataKeys.AddFriend.USER_ID - GetSocial user ID.

Handled by GetSocial UI

  • ActionTypes.OPEN_INVITES: Will open Smart Invites view. Has no required parameters.
  • ActionTypes.OPEN_ACTIVITY: Will open Activity Feed. To open Activity Feed list provide following parameter:

    • ActionDataKeys.OpenActivity.FEED_NAME - Feed to Open. Use ActivitiesQuery.GLOBAL_FEED to open global feed.

    To open Activity Feed post itself and optionally scroll to the certain comment provide following parameters:
    - ActionDataKeys.OpenActivity.ACTIVITY_ID - Activity Feed post ID.
    - ActionDataKeys.OpenActivity.COMMENT_ID - Comment under that activity. Optional.

Not Handled

The following action is not handled by GetSocial:

  • ActionTypes.OPEN_PROFILE. Required parameters:
    • ActionDataKeys.OpenProfile.USER_ID - GetSocial user ID whose profile should be opened.

Give us your feedback! Was this article helpful?

😀 🙁