Skip to content

GetSocial UI on Unity


Show GetSocial UI View

To create GetSocial View you have to build it first of all. All GetSocial ViewBuilders extend from GetSocialSdk.Ui.ViewBuilder class.

ViewBuilder viewBuilder = ...;//build view here

bool wasShown = viewBuilder.Show();
//bool wasShown = GetSocialUi.ShowView(viewBuilder);

Both of the methods will show GetSocial View on top of the current activity and return true if the view was shown, or false otherwise. You can find an error, why GetSocial View was not shown in your platform console(LogCat for Android or Xcode console for iOS).

Let’s create Smart Invites View as an example:

ViewBuilder viewBuilder = InvitesViewBuilder.Create();

Custom Titles

All GetSocial Views have default localized titles, but you can easily set a custom one as well. In this case, you’ll need to handle localization on your own. Here’s how you can set a title for Smart Invites View:

    .SetWindowTitle("Share with Friends!")

And voi la - your window now has a new title. To handle localization, you can use GetSocial.GetLanguage() method to get the current language, all supported language codes are placed in GetSocialSdk.Core.LanguageCodes. Read more about Localization here.

Control GetSocial View State

GetSocial UI provides you with all the instruments to control the state of its views. You have already read how to show GetSocial View. Now let’s try closing it. Do this with:

bool saveState = false;

It will close current visible GetSocial View or do nothing if there is no GetSocial View.

It you want to close GetSocial View saving its current state and restore it later, pass true as saveState parameter:

//close and save
bool saveState = true;

//and restore


If you want to show new GetSocial view after you closed other with saving state, your saved state will be lost, and the view will be opened as usual. Calling RestoreView after that will not affect anything.

View State Events

If you want to be notified about onOpen and onClose events of GetSocial View, you can set callbacks to a view before showing it.

    .SetViewStateCallbacks(() =>
        // GetSocial View was opened
    }, () =>
        // GetSocial View was closed

UI User Actions Handling

GetSocial UI does all the job of communicating with the underlying GetSocial Data API for you. However, sometimes, you may want to customize the behavior of GetSocial UI and have more control over user’s actions. That is why we introduced UiActionListener. When you create GetSocial View, you can set a listener to be notified about user’s events, track them, allow or disallow, etc.:

    .SetUiActionListener((action, pendingAction) =>
        CheckIfAllowed(action, () => pendingAction());

All possible events are listed in UiAction enumeration.


If you did not set a UiActionListener, all actions are executed as usual, but if you set it, you have to call pendingAction() action each time when you want to execute an action. Otherwise, it will not be performed.

For example, if the user is not authorized, you could prompt him to log in with Facebook and add an identity in your CheckIfAllowed(...) method, and in case of success - proceed with an action. Proceeding can be done asynchronously.

Also, you can track events using your internal analytics.


If you have some problems showing an alert or view while GetSocial UI View is opened, call GetSocialUi.CloseView(true). Later, after your view is closed, call GetSocialUi.RestoreView() and pendingAction() if you want to perform an action, or just GetSocialUi.RestoreView() to get back to GetSocial UI View.

Handle Back Button (Android only)

If you want to enable navigation with back button between GetSocial views, you need to handle KeyCode.Escape key:

if (Input.GetKeyDown(KeyCode.Escape))
    if (!GetSocialUi.OnBackPressed())
        // You can put your own logic here - event is not handled by GetSocial

If GetSocialUi.OnBackPressed() returns true, back press was handled by GetSocial UI. If it returns false - handle it on your own.


GetSocialUi.OnBackPressed method exists only for Android compile time, so you have to wrap it with #if UNITY_ANDROID ... #endif, otherwise you will have a compile error in iOS.

Load UI Configuration

To customize GetSocial UI you have to provide custom assets (drawables, fonts) and JSON configuration file. The easiest way to start, is to download one of the included themes (Default, Dark or Light) and do small tweaks on the JSON configuration (see the reference) or resources.

On Unity, all assets, as well as UI configuration JSON, should be located in the Assets/StreamingAssets/ folder.

For instance, to make GetSocial UI wider for landscape orientation you have to:

  1. Create a UI configuration file, e.g. getsocial/ui-landscape.json with the following content:

            "base-design": {
                "scale-mode": "scale-with-screen-size",
                "width": 640,
                "height": 320,
                "ppi": 72
            "elements": {
                "window": {
                    "width": 500,
                    "height": 320
  2. Load UI configuration. In Unity Editor go to GetSocial menu → Edit Settings

  3. In General Settings section, set the path to the configuration file relative to StreamingAssets/ folder:

    Setup UI Configuration in Unity

    Or you can load it dynamically from code:

    bool wasLoaded = GetSocialUi.LoadConfiguration("getsocial/ui-landscape.json");
    Debug.Log("UI configuration was loaded successfully: " + wasLoaded);

    GetSocialUi.LoadConfiguration(…) is Deprecated

    Loading UI Configuration from code has a limitation: you have to load it at each entry point to the app, e.g., when users open the app from a push notification.
    On the contrary, when you provide the path to UI Configuration in GetSocial Settings we handle UI Configuration loading automatically.

Next Steps

Give us your feedback! Was this article helpful?

😀 🙁