Skip to content

Send Your First Smart Invite on React Native

Prerequisite

Send Smart Invites

GetSocial SDK provides currently supports sending invites 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 link params with key-value pairs you want to attach to the Smart Link:

const linkParams = new Map();
linkParams.set("custom_key", "custom_value"); // custom key
linkParams.set("$title", "Custom landing page title"); // predefined key

Supported value types

The linkParams map 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:

const customInviteContent = new CustomInviteContent()
    .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.withImageUrl("https://docs.getsocial.im/images/logo.png"));

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.

const inviteChannelId = 'facebook';

// Check if invite channel is available on the device.
// Alternatively you can get all available channels via GetSocial.getInviteChannels()
GetSocial.isInviteChannelAvailable(inviteChannelId).then((isAvailable) => {
    if (isAvailable) {
        GetSocial.sendInvite(channelId, inviteContent, linkParams, () => {
            console.log('Invitation with referral data via FACEBOOK was sent');
        }, () => {
            console.log('Invitation with referral data via FACEBOOK was cancelled');
        }, (error) => {
            console.log('Invitation with referral data via FACEBOOK failed, error: ' + error);
        });
    } else {
        console.log('FACEBOOK invite channel is not available.');
    }
});

Facebook Share Dialog will be presented as a result:

GetSocial Smart Ivites View

Send Invites Using 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 create and show the view:

GetSocialUI.createInvitesView()
    .withCustomInviteContent(customInviteContent)
    .withInviteUICallback((channelId) => {
        console.log('Smart Invite', 'Invite was sent using ' + channelId);
    }, (channelId) => {
        console.log('Smart Invite', 'Invite sending was canceled, channel: ' + channelId);
    }, (channelId, error) => {
        console.log('Smart Invite', 'Failed to send invite, error: ' + error);
    });
    .show();

You will see the following view on your screen:

GetSocial Smart Ivites View

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:

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

GetSocial.createInviteLink(linkParams).then((inviteLink) => {
    console.log('Invite link: ' + inviteLink);
}, (error) => {
    console.log('Failed to create invite link, error: ' + error);
});

Next Steps

Give us your feedback! Was this article helpful?

😀 🙁