GetSocial React Native SDK Manual Initialization Guide

Disable Auto Initialization

By default, GetSocial SDK initializes automatically on application start. You can disable this behavior and initialize from code.

Android

If you’re using GetSocial Gradle plugin, set autoInit flag to false in your build.gradle file:

1
2
3
4
5
6
apply plugin: 'im.getsocial'

getsocial {
    appId "LK8A9cA0o07"
    autoInit false
}

If you’re not using Gradle plugin, add <meta-data> to your <application> tag in AndroidManifest.xml:

1
2
3
4
5
<application android:label="@string/app_name" ...>
    ...
    <meta-data android:name="im.getsocial.sdk.AutoInitSdk" android:value="false"/>
    ...
</application>

iOS

Using GetSocial Installer Script

If you are using GetSocial Installer script, to disable auto initialization:

  1. In your Xcode project, open Project settings and select target you want to modify.
  2. Go to Build Phases tab → Run Script section and add --auto-init parameter to GetSocial configuration:

    1
    ./getsocial.sh --app-id="your-getsocial-app-id" --auto-init="false"
    

Using Info Plist Property

If you are not using GetSocial Installer script you have to add .plist property manually:

  1. In your Xcode project, open .plist file.
  2. Add property im.getsocial.sdk.AutoInitSdk:

    1
    2
    <key>im.getsocial.sdk.AutoInitSdk</key>
    <false/>
    

Initialize From Code

To initialize GetSocial SDK from code, just call:

1
GetSocial.init();

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

1
2
3
GetSocial.whenInitialized(() => {
    // GetSocial SDK is ready to use
});

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
componentWillMount(){
    GetSocial.whenInitialized(() => {
        GetSocial.getReferralData().then((referralData) => { 
            // process referral data 
        });
    });
    GetSocial.init();
}

Initialize With Dynamic Application Id

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

1
2
const appId = ...;
GetSocial.initWithAppId(appId);

Give us your feedback! Was this article helpful?

😀 🙁