Skip to content

Send and Receive Your First Smart Invite on Unity

Prerequisite

Send Smart 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.

You can attach string-string key-value pairs to pass custom data with a Smart Link. Also, you can add one of the predefined parameters to change the behaviour of the Smart Link.

Receiving user can get the data attached to the Smart Link on the app start, even if an app was just installed from the store.

To create LinkParams object with key-value pairs you want to attach to the Smart Link:

var linkParams = new LinkParams();
linkParams.Add("custom_key", "custom_value"); // custom key
linkParams.Add("$title", "Custom landing page title"); // predefined key

Supported value types

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

Customize Invite Message Content

Some invite channels allow to customize text, image and subject. Check the details here.

Default Smart Invites message can be defined on the GetSocial DashboardAcquisition section → Smart Invites tab.

To customize content on the client side:

var inviteContent = InviteContent.CreateBuilder()
        .WithText("I can't stop playing! Get it here [APP_INVITE_URL]") // NOTE: if you customize the text [APP_INVITE_URL] placeholder have to be used
        .WithSubject("Check out this app")
        .WithMediaAttachment(MediaAttachment.ImageUrl("https://docs.getsocial.im/images/logo.png"))
        .Build();

Send Invites Using GetSocial Data API

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

var inviteChannelId = InviteChannelIds.Facebook;

// Check if invite channel is available on the device.
// Alternatively you can get all available channels via GetSocial.InviteChannels
if(GetSocial.IsInviteChannelAvailable(inviteChannelId)) {

    GetSocial.SendInvite(inviteChannelId, inviteContent, linkParams,
        onComplete: () => Debug.Log("Customized invitation via FACEBOOK was sent"),
        onCancel: () => Debug.Log("Customized invitation via FACEBOOK was cancelled"),
        onFailure: (error) => Debug.LogError("Customized invitation via FACEBOOK failed, error: " + error.Message)
    );
}

After calling this method Facebook share dialog will be opened:

GetSocial Smart Ivites View

Send Invites Using GetSocial Smart Invites View

GetSocial UI library provide 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 create and show the view:

bool wasShown = GetSocialUi.CreateInvitesView()
    .SetLinkParams(linkParams)
    .SetCustomInviteContent(inviteContent)
    .SetInviteCallbacks(
        onComplete: (channelId) => Debug.Log("Invitation was sent via " + channelId),
        onCancel: (channelId) => Debug.Log("Invitation via " + channelId +" was cancelled"),
        onFailure: (channelId, error) => Debug.LogError("Invitation via" + channelId + "failed, error: " + error.Message)
    )
    .Show();

    Debug.Log("Smart Invites view was shown: " + wasShown);

You will see the following view on your screen:

GetSocial Smart Ivites View

Send a GIF

With our gif capturing library you can record and share gameplay with Smart Invite. More info

GetSocial.SendInvite() and GetSocialUi.CreateInvitesView() are opening the selected invite channel with pre-filled invite message. If you want to handle sharing on your own and just need a Smart Link to invite uses you can use the following API:

var linkParams = new LinkParams();
linkParams.Add("$channel", "my_custom_channel"); // optional: set sharing channel for analytics, by default channel is set to "manual"

GetSocial.CreateInviteLink(linkParams,
        (string smartLink) => Debug.Log("Created invite link: " + smartLink),
        error => Debug.LogError(string.Format("Failed to create invite link: {0}", error.Message))
    );

Next Steps

Give us your feedback! Was this article helpful?

😀 🙁