Skip to content

GetSocial Unity SDK Manual Initialization Guide

Disable Auto Initialization

GetSocial SDK is initialized automatically. To prevent this behaviour:

  1. Open GetSocial Unity Editor, from the Unity menu go to GetSocialEdit Settings.
  2. Disable Initialize Automatically checkbox in General Settings section:

    GetSocial Manual Initialization

Initialize From Code

To initialize GetSocial SDK from code, just call GetSocial.Init().

Most of GetSocial APIs require initialized SDK. You can check SDK initialization state in sync or async way.

if (GetSocial.IsInitialized) {
    // use GetSocial
}

If you want to be notified about initialization complete, you can set an action, that will be invoked when SDK gets initialized or invoked immediately if it is already initialized:

GetSocial.AddOnInitializedListener(() => {
    // GetSocial is ready to be used
});

It can be useful when you want to use GetSocial on application start, but you can not be sure is it ready for use, for example, you want to retrieve referral data on application start:

public class Controller : MonoBehaviour
{
    ...
    void Awake()
    {
        ...
        GetSocial.AddOnInitializedListener(() => {
            GetSocial.GetReferralData(...);
        });
        GetSocial.Init();
        ...
    }
    ...
}

Initialize With Dynamic Application Id

Also, you can specify application ID to initialize with from code:

string appId = ...;
GetSocial.Init(appId);

Give us your feedback! Was this article helpful?

😀 🙁