Essential Smart Invites Setup on Unity

In this guide we will go through all steps needed for basic configuration of GetSocial Smart Invites. Let’s get to the work!

Prerequisite

Setup Invite Channels

GetSocial Smart Invites has two types of Invite Channels:

  • The one that work out of the box, e.g. SMS, Email, WhatsApp, Messenger, Kik, Line, Twitter.
  • Ones that require integration of 3rd-party SDKs: Facebook.

In this step we will integrate GetSocial with the 3rd-party SDKs.

Setup Integration with Facebook SDK

GetSocial is compatible with Facebook Unity SDK v7.x, older versions are not supported. Integration do not require Facebook application installed to be able to send invitations.

Facebook is deprecating App Invites

Facebook is deprecating App Invites from February 5, 2018.

New GetSocial integration with Facebook will allow posting Smart Invite to the timeline, friend’s timeline or a group. To upgrade, replace FacebookInvitePlugin with FacebookSharePlugin .

More: https://blog.getsocial.im/facebook-deprecates-app-invites-are-you-ready/

  1. Integrate Facebook Unity SDK into your app as described in the Official Guide.
  2. Copy implementation of the Facebook Share plugin from GetSocial GitHub repository into your project.
  3. Register plugin with GetSocial before inviting via Facebook. We recommend registering in GameObject.onStart() method:

    1
    2
    3
    4
    void Start () {
        // ... other code
        GetSocial.RegisterInviteChannelPlugin(InviteChannelIds.Facebook, new FacebookSharePlugin());
    }
    
  4. To validate integration, open the GetSocial Smart Invites view:

    1
    GetSocialUi.CreateInvitesView().Show();
    

    The list should contain Facebook:

    GetSocial Smart Ivites View

Send Your First Smart Invite

To send your first Smart Invite invoke the method below. All supported Invite Channels are listed in InviteChannelIds class.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
GetSocial.SendInvite(InviteChannelIds.Email,
        onComplete: () => Debug.Log("Invitation via EMAIL was sent"),
        onCancel: () => Debug.Log("Invitation via EMAIL was cancelled"),
        onFailure: (error) => Debug.LogError("Invitation via EMAIL failed, error: " + error.Message)
    );


After calling this method email client will be opened:

<center><img src="/images/getting-started/si-over-email.png" alt="GetSocial Smart Ivite over Email" width="250"/></center>

Open 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 open the view and register Invite callback:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
bool wasShown = GetSocialUi
    .CreateInvitesView()
    .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

Next Steps

Give us your feedback! Was this article helpful?

😀 🙁