Skip to content

Actions

To create an action use GetSocialActionBuilder:

1
2
GetSocialActionBuilder *builder = [[GetSocialActionBuilder alloc] initWithType:@"my-custom-action"];
GetSocialAction *action = [builder build];
1
2
let builder = GetSocialActionBuilder.init(type: GetSocialActionType.custom)
let action = builder.build()

Add action data using [builder addActionDataValue:(NSString *)value forKey:(NSString *)key] or [builder addActionData:(NSDictionary<NSString *, NSString *> *)data] - second one will add all the keys and values from parameter map. For the default GetSocial actions use one of GetSocialActionDataKey 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:

1
2
3
GetSocialActionBuilder *builder = [[GetSocialActionBuilder alloc] initWithType:GetSocialActionOpenActivity];
[builder addActionData:@{ GetSocialActionDataKey_OpenActivity_FeedName: @"funny-stories" }];
GetSocialAction *action = [builder build];
1
2
3
let builder = GetSocialActionBuilder.init(type: GetSocialActionType.openActivity)
builder.addActionDataValue("funny-stories", withKey: GetSocialActionDataKey._OpenActivity_ActivityId.rawValue)
let action = builder.build()

Currently you can attach actions to notifications or activity posts.

Handle Actions

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
- (BOOL)handleAction:(GetSocialAction *)action
{
    if ([action.type isEqualToString:GetSocialActionOpenProfile]) // handle GetSocial action
    {
        [self showNewFriend:action.data[GetSocialActionDataKey_OpenProfile_UserId]];
        return YES;
    }
    if ([action.type isEqualToString:@"try-campaign-mode"]) // handle custom action
    {
        [self startCampaignMode];
        return YES;
    }
    // Other actions are handled by GetSocial.
    return NO;
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
func handle(_ action: GetSocialAction) -> Bool {
    if (action.type == GetSocialActionType.openProfile) {
        showNewFriend(action.data[GetSocialActionDataKey._OpenProfile_UserId])
        return true
    }
    if (action.type.rawValue == "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 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:(GetSocialAction *)action];
1
GetSocial.processAction(action: GetSocialAction);

Handled by GetSocial Core

  • GetSocialActionOpenUrl: Will open a system web browser with provided URL. Required parameters:
    • GetSocialActionDataKey_OpenUrl_Url - URL to open.
  • GetSocialActionAddFriend: Add user the the list of friends on Social Graph. Parameters:
    • GetSocialActionDataKey_AddFriend_UserId - GetSocial user ID.
  • GetSocialActionClaimPromoCode: Claim a promo code. You can get the information about claiming via Webhook. We recommend you to override default behavior and call [GetSocial claimPromoCode:] to have a feedback about success inside the app.
    • GetSocialActionDataKey_ClaimPromoCode_PromoCode - promo code to claim.

Handled by GetSocial UI

  • GetSocialActionOpenInvites: Will open Smart Invites view. Has no required parameters.
  • GetSocialActionOpenActivity: Will open Activity Feed. To open Activity Feed list provide following parameter:

    • GetSocialActionDataKey_OpenActivity_FeedName - Feed to Open. Use GetSocial_ActivityFeed_GlobalFeed to open global feed.

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

Not Handled

The following action is not handled by GetSocial:

  • GetSocialActionOpenProfile. Required parameters:
    • GetSocialActionDataKey_OpenProfile_UserId - GetSocial user ID whose profile should be opened.

Give us your feedback! Was this article helpful?

😀 🙁