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.

1
2
3
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:

1
2
3
GetSocial.WhenInitialized(() => {
    // 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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
public class Controller : MonoBehaviour
{
    ...
    void Awake()
    {
        ...
        GetSocial.WhenInitialized(() => {
            GetSocial.GetReferralData(...);
        });
        GetSocial.Init();
        ...
    }
    ...
}

Initialize With Dynamic Application Id

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

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

Give us your feedback! Was this article helpful?

😀 🙁