Initialize SDK

Prev Next

You can follow these steps to initialize the SDK.

1. Init Insider SDK in your Application Class (landing class).

Keep in mind that "your_partner_name" is the given name of the app panel on the Insider side. You can gather this info from Insider One team, or you can log in to the InOne panel and navigate it yourself. It is placed at the top right of the panel, next to the username. Use lowercase only.

import android.app.Application;

import com.useinsider.insider.Insider;

public class MyApplicationClass extends Application {
   @Override
   public void onCreate(){
       super.onCreate();
       // DO NOT FORGET to change your_partner_name.
       // Use only lowercase and your_partner_name is provided by Insider.
       Insider.Instance.init(this, "your_partner_name");
   }

}
import android.app.Application
 import com.useinsider.insider.Insider

 class MyApplicationClass : Application() {
     override fun onCreate() {
         super.onCreate()
         // DO NOT FORGET to change your_partner_name.
         // Use only lowercase. your_partner_name is provided by Insider.
         Insider.Instance.init(this, "your_partner_name")
     }
 }
Make sure that you have initialized Insider SDK in your application class. Please avoid initializing it in the activity class. During your Integration, if you're using your UAT panel, make sure to update "your partner name" value to migrate integration to the live panel.

2. Register your Splash Activity

This step is optional. Call setSplashActivity only if your app has a dedicated Splash Activity that you want the SDK to recognize and skip when surfacing In-App campaigns. If you don't have a splash screen, omit this call entirely; the previous step is enough for initialization.

When you have a Splash Activity, calling setSplashActivity prevents Insider In-App messages from appearing on top of it. Call it immediately after the init.

import android.app.Application;

import com.useinsider.insider.Insider;

public class MyApplicationClass extends Application {
   @Override
   public void onCreate(){
       super.onCreate();
       // DO NOT FORGET to change your_partner_name.
       // Use only lowercase and your_partner_name is provided by Insider.
       Insider.Instance.init(this, "your_partner_name");
      
       // DO NOT FORGET to change MySplashActivity.class
       Insider.Instance.setSplashActivity(MySplashActivity.class);
   }

}
import android.app.Application
import com.useinsider.insider.Insider

class DemoApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        // DO NOT FORGET to change your_partner_name.
        // Use only lowercase and your_partner_name is provided by Insider.
        Insider.Instance.init(this, "your_partner_name")

        // TODO: Add your splash activity.
        // Insider.Instance.setSplashActivity(Splash.activity);

    }
}

Late initialization

Late initialization requires Insider Android SDK 14.10.5 or later. If your application uses an earlier SDK version, update the Insider SDK before implementing this flow.

However, some applications may need to wait for user consent, authentication, or an asynchronous configuration process before initializing the SDK. If the application initializes the SDK after the first Activity has already resumed, call completeDeferredInit() immediately after init().

completeDeferredInit() completes the lifecycle operations that could not run during the standard application startup. It starts the session, handles the pending push launch, requests the remote configuration, and processes supported events or actions queued during deferred initialization.

Consent-gated init: if GDPR consent has been explicitly set to false, completeDeferredInit() performs none of these operations and does not retry them later on its own. Applications that gate initialization on consent must call setGDPRConsent(true) before calling completeDeferredInit(). (This only affects apps that explicitly set consent to false. The SDK default is true.)

Use late initialization only when your application flow requires it. Otherwise, keep the standard initialization in Application.onCreate().

Remove the standard initialization call from the Application class:

import android.app.Application;

public class MyApplicationClass extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        // Do not initialize the SDK here when using late initialization.
        // Insider.Instance.init(this, "your_partner_name");
    }
}
import android.app.Application

class MyApplicationClass : Application() {

    override fun onCreate() {
        super.onCreate()

        // Do not initialize the SDK here when using late initialization.
        // Insider.Instance.init(this, "your_partner_name")
    }
}

Initialize the SDK after the required process is complete:

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.useinsider.insider.Insider;

public class MainActivity extends AppCompatActivity {

    private boolean isInsiderInitialized = false;

    @Override
    protected void onResume() {
        super.onResume();

        initializeInsiderIfRequired();
    }

    private void initializeInsiderIfRequired() {
        if (isInsiderInitialized) {
            return;
        }

        // The actual gate — return until the async prerequisite is satisfied.
        if (!consentManager.isMarketingConsentGranted()) {
            return;
        }

        Insider.Instance.init(
            getApplication(),
            "your_partner_name"
        );

        Insider.Instance.setGDPRConsent(true);

        Insider.Instance.completeDeferredInit(this);

        isInsiderInitialized = true;
    }
}
import androidx.appcompat.app.AppCompatActivity
import com.useinsider.insider.Insider

class MainActivity : AppCompatActivity() {

    private var isInsiderInitialized = false

    override fun onResume() {
        super.onResume()

        initializeInsiderIfRequired()
    }

    private fun initializeInsiderIfRequired() {
        if (isInsiderInitialized) {
            return
        }

        // The actual gate — return until the async prerequisite is satisfied.
        if (!consentManager.isMarketingConsentGranted()) {
            return
        }

        Insider.Instance.init(
            application,
            "your_partner_name"
        )

        Insider.Instance.setGDPRConsent(true)

        Insider.Instance.completeDeferredInit(this)

        isInsiderInitialized = true
    }
}