Skip to content

Actions

To create an action use Action.create method:

let action = Action.create(type: ActionType.addFriend)

Add action data using Action.create(type: data:) method. For the default GetSocial actions use one of ActionDataKey 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:

let action = Action.create(type: ActionType.OpenActivity, data: [ActionDataKey.OpenActivity_ActivityId: "funny-stories"])

Currently you can attach actions to notifications or activity posts.

Handle Actions

func handle(_ action: Action) -> Bool {
    if (action.type == ActionType.openProfile) {
        showNewFriend(action.data[ActionDataKey.openProfile_UserId])
        return true
    }
    if (action.type == "try-campaign-mode") {
        startCampaignMode()
        return true
    }
    // 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 handle(_ action: Action) 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

  • ActionType.openUrl: Will open a system web browser with provided URL. Required parameters:

    • ActionDataKey.openUrl_Url - URL to open.
  • ActionType.addFriend: Add user the the list of friends on Social Graph.

    • ActionDataKey.addFriend_UserId - GetSocial user ID.
  • ActionType.claimPromoCode: Claim a promo code. You can get the information about claiming via Webhook. We recommend you to override default behavior and call PromoCodes.claim(code) to have a feedback about success inside the app.

    • ActionDataKey.claimPromoCode_PromoCode - promo code to claim.

Handled by GetSocial UI

  • ActionType.openInvites: Will open Smart Invites view. Has no required parameters.
  • ActionType.openActivity: Will open Activity Feed. To open Activity Feed list provide following parameter:

    • ActionDataKey.openActivity_FeedName - Feed to Open.

    To open Activity Feed post itself and optionally scroll to the certain comment provide following parameters:
    - ActionDataKey.openActivity_ActivityId - Activity Feed post ID.
    - ActionDataKey.openActivity_CommentId - Comment under that activity. Optional.
    - ActionDataKey.openActivity_TopicId - Source of activity. Optional.

  • ActionType.openTopic: Will open feed of Topic.

    • ActionDataKey.openTopic_TopicId: Topic to open.

Not Handled

The following action is not handled by GetSocial:

  • ActionType.openProfile. Required parameters:
    • ActionDataKey.openProfile_UserId - GetSocial user ID whose profile should be opened.

Give us your feedback! Was this article helpful?

😀 🙁