Actions¶
Create Action¶
To create an action use builder
method:
const action = Action.withType('my-custom-action');
Add action data using addActionData(key: string, value: string)
or addActionData(actionData: Map<string, string>)
- second one will add all the keys and values from parameter map. For the default GetSocial actions use one of constants to guarantee the default behavior. 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:
const action = Action.withType(Action.Types.OPEN_URL)
.addActionData(Action.DataKeys.OPEN_URL.URL, 'https://getsocial.im');
Currently you can attach actions to notifications.
Handle Actions¶
handleAction(action: Action) {
if (action.type == 'try-campaing-mode') {
startCampaignMode();
}
// Default actions are handled by GetSocial.
}
To handle custom actions use:
- Notification listener in Smart Notifications.
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 handle(...)
method to process them. We use it internally in GetSocial UI. For you it may be helpful when building your custom UI.
GetSocial.handle(action);
Handled by GetSocial Core¶
Action.Types.OPEN_URL
: Will open a system web browser with provided URL. Required parameters:Action.DataKeys.OPEN_URL.URL
- URL to open.
Action.Types.ADD_FRIEND
: Add user the the list of friends on Social Graph. Parameters:Action.DataKeys.ADD_FRIEND.USER_ID
- GetSocial user ID.
Handled by GetSocial UI¶
Action.Types.OPEN_INVITES
: Will open Smart Invites view. Has no required parameters.
Not Handled¶
The following action is not handled by GetSocial:
Action.Types.OPEN_PROFILE
. Required parameters:Action.DataKeys.OPEN_PROFILE.USER_ID
- GetSocial user ID whose profile should be opened.