Skip to content

Actions

To create an action use GetSocialActionBuilder:

1
2
GetSocialActionBuilder *builder = [[GetSocialActionBuilder alloc] initWithType:GetSocialActionCustom];
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 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
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 Action

 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

  1. Open User Profile.

    GetSocialActionOpenProfile is not handled by SDK. Parameters:

    • GetSocialActionDataKey_OpenProfile_UserId - GetSocial user ID whose profile should be opened.
  2. Open Activity Feed.

    GetSocialActionOpenActivity is handled by SDK. Will open activity feed with provided name, or activity feed post itself or scroll to the certain comment if provided. Parameters:

    • GetSocialActionDataKey_OpenActivity_ActivityId - Activity Feed post ID.
    • GetSocialActionDataKey_OpenActivity_CommentId - Comment under that activity. Optional.

    or:

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

    GetSocialActionOpenInvites is handled by SDK. Will open Smart Invites screen. Has no required parameters.

  4. Open URL.

    GetSocialActionOpenUrl is handled by SDK. Wil open a system web browser with provided URL. Parameters:

    • GetSocialActionDataKey_OpenUrl_Url - URL to open.

Process Action

To process an action by GetSocial, use [GetSocial processAction:(GetSocialAction *)action]. It might be useful for custom notification center.

Give us your feedback! Was this article helpful?

😀 🙁