Send Your First Smart Invite on Android

Prerequisite

Send Invites

GetSocial SDK provides two ways to send Smart Invites: using our data API or via provided GetSocial UI.

Smart Invites are powered by Smart Links. Internally we generate a unique Smart Link for each invitation and attach information about the sender to the Smart Link.

Also, we expose API to attach any string-string key-value pairs to the Smart Link. Receiving user can get the data attached to the Smart Link on the app start, even if the app was just installed from the store.

Check the code below for examples.

Using GetSocial Data API

The code below shows how to send Smart Invite with custom data attached via a Facebook channel. All supported Invite Channels are listed in InviteChannelIds class.

Reserved Parameters

Keys starting with $ are reserved by GetSocial. See here for a reference of all such keys.

Supported value types

The LinkParams object supports String values for custom data, other types will be ignored.

  1. Create LinkParams object with key-value pairs you want to attach to the Smart Link:

    1
    2
    3
    LinkParams linkParams = new LinkParams();
    linkParams.put("key1", "value1");
    linkParams.put("key2", "value2");
    
  2. Use GetSocial Data API to send invitation with LinkParams attached:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    String inviteChannel = InviteChannelIds.FACEBOOK;
    InviteContent inviteContent = InviteContent.createBuilder().build();
    
    GetSocial.sendInvite(inviteChannel, inviteContent, linkParams, new InviteCallback() {
        @Override
        public void onComplete() {
            Log.i("GetSocial", "Invitation with referral data via FACEBOOK was sent");
        }
    
        @Override
        public void onCancel() {
            Log.i("GetSocial", "Invitation with referral data via FACEBOOK was cancelled");
        }
    
        @Override
        public void onError(Throwable throwable) {
            Log.e("GetSocial", "Invitation with referral data via WHATSAPP failed, error: " + throwable.getMessage());
        }
    });
    

Facebook Share Dialog will be presented as a result:

GetSocial Smart Ivites View

Open GetSocial Smart Invites View

GetSocial UI library provides a view that lists all Smart Invite channels available on the device and enabled on the GetSocial Dashboard.

To send an invite with custom data attached using GetSocial UI:

Reserved Parameters

Keys starting with $ are reserved by GetSocial. See here for a reference of all such keys.

Supported value types

The LinkParams object supports String values for custom data, other types will be ignored.

  1. Create LinkParams object with key-value pairs you want to attach to the Smart Link:

    1
    2
    3
    LinkParams linkParams = new LinkParams();
    linkParams.put("key1", "value1");
    linkParams.put("key2", "value2");
    
  2. Create and show the view:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    boolean wasShown = GetSocialUi.createInvitesView()
            .setLinkParams(linkParams)
            .setInviteCallback(new InviteUiCallback() {
                @Override
                public void onComplete(String channelId) {
                    Log.i("GetSocial", "Invitation was sent");
                }
    
                @Override
                public void onCancel(String channelId) {
                    Log.i("GetSocial", "Invite cancelled");
                }
    
                @Override
                public void onError(String channelId, Throwable throwable) {
                    Log.e("GetSocial", "Invite failed: " + throwable.getMessage());
                }
            })
            .show();
    
    Log.i("GetSocial", "GetSocial Smart Invites UI was shown: " + wasShown);
    

You will see the following view on your screen:

GetSocial Smart Ivites View

Retrieve Referral Data

Smart Invites are powered by Smart Links. To retrieve data attached to the invitation you have to follow Receiving Smart Links guide.

Retrieve Referred Users

Using GetSocial data API you can retrieve the list of users who installed application from the invitations sent by current user:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
GetSocial.getReferredUsers(new Callback<List<ReferredUser>>() {
    @Override
    public void onSuccess(List<ReferredUser> result) {
        if (result.size() > 0) {
            // current user invited others to the app
        }

        @Override
        public void onFailure(GetSocialException exception) {
            Toast.makeText(MainActivity.this, "Failed to retrieve ReferredUsers, error: " + error, Toast.LENGTH_LONG).show();
        }
});

ReferredUser 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 ReferredUser object installationDate value is after reward check date, you can give the reward.
  3. Update reward check date to current date.

Next Steps

Give us your feedback! Was this article helpful?

😀 🙁