Skip to content

Actions

Create Action

To create an action use builder method:

1
Action action = Action.builder(ActionTypes.CUSTOM).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

  1. Open User Profile.

    ActionTypes.OPEN_PROFILE is not handled by GetSocial. Parameters:

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

    ActionTypes.OPEN_ACTIVITY 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:

    • ActionDataKeys.OpenActivity.ACTIVITY_ID - Activity Feed post ID.
    • ActionDataKeys.OpenActivity.COMMENT_ID - Comment under that activity. Optional.

    or:

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

    ActionTypes.OPEN_INVITES is handled by GetSocial UI. Will open Smart Invites screen. Has no required parameters.

  4. Open URL.

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

    • ActionDataKeys.OpenUrl.URL - URL to open.

Process Action

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

Give us your feedback! Was this article helpful?

😀 🙁