Sending and Receiving Referral Data

You can attach any key-value data to GetSocial Smart Invites and Smart Links. Receiving user can get the data from the invite or link even if the was was just installed from the store.

Prerequisite

Send Referral Data

Referral Data is map of string-string key-value pairs that are attached to the Invite Link. It is possible to attach custom data when sending invitation via GetSocial Data API and GetSocial UI. The code below shows how to do so:

  1. Create an NSMutableDictionary object with key-value pairs you want to attach to the Invite Link:

    1
    2
    3
    NSMutableDictionary* customReferralData = [NSMutableDictionary dictionary];
    [customReferralData setValue:@"value1" forKey:@"key1"];
    [customReferralData setValue:@"value2" forKey:@"key2"];
    
  2. If you are building invitation UI on your own, use GetSocial Data API to send invitation with custom referral data attached:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    GetSocialMutableInviteContent* inviteContent = [GetSocialMutableInviteContent new];
    
    [GetSocial sendInviteWithChannelId:GetSocial_InviteChannelPluginId_Facebook inviteContent:inviteContent customReferralData:customReferralData success:^{
        NSLog(@"Invitation with referral data via FACEBOOK was sent");
    } cancel:^{
        NSLog(@"Invitation with referral data via FACEBOOK was cancelled");
    } failure:^(NSError * _Nonnull error) {
        NSLog(@"Invitation with referral data via FACEBOOK failed, error: %@", error.description);
    }];
    
  3. Or, if you are using GetSocial UI, attach custom referral data to the view:

    1
    2
    3
    GetSocialUIInvitesView* invitesView = [GetSocialUI createInvitesView];
    [invitesView setCustomReferralData:customReferralData];
    [invitesView show];
    

Retrieve Referral Data

It is possible to retrieve Referral Data attached to the Invite Link in two cases:

  • On the first launch after the app was installed from clicking on the GetSocial Invite or Smart Link.
  • When the app was opened from clicking on the GetSocial Invite or Smart Link.

The code below show how to do it:

1
2
3
4
5
6
7
8
9
[GetSocial referralDataWithSuccess:^(GetSocialReferralData * _Nullable referralData) {
    if (referralData != nil) {
        NSLog(@"App started with Referral Data: %@", referralData);
    } else {
        NSLog(@"No Referral Data found");
    }
} failure:^(NSError * _Nonnull error) {
    NSLog(@"Failed to retrieve Referral Data, error: %@", error.description);
}];

No Referral Data after install from Facebook App Invite?

Make sure that you or any other 3rd party library (e.g. Branch.io) are not calling FBSDKAppLinkUtility.fetchDeferredAppLink method. Facebook SDK will return data associated with the deep link only on the first call. If someone will call it before GetSocial, you will not get Referral Data.

Returned referral data contains custom data attached to the link, metainformation about the channel, user who sent an invitation, etc. For a full list of available properties check the GetSocialReferralData reference.

Retrieve Referred Users

You can also check the list of invited users of current user:

1
2
3
4
5
6
7
[GetSocial referredUsersWithSuccess:^(NSArray<GetSocialReferredUser *> * _Nonnull referredUsers) {
    if (referredUsers.count > 0) {
        // current user invited others to the app
    }
} failure:^(NSError * _Nonnull error) {
    NSLog(@"Failed to retrieve Referred Users, error: %@", error.description);
}];

GetSocialReferredUser object contains user details, including installationDate, which is the date when the invited user installed the app.

This way for example you can reward your users for inviting other users:

  1. Read last reward check date from local storage.
  2. If GetSocialReferredUser object installationDate value is after reward check date, you can give reward.
  3. Update reward check date to current date.

Next Steps

Give us your feedback! Was this article helpful?

😀 🙁