Skip to main content

Nuclei SDK Intialisation

Initialisation

Nuclei SDK should be initialised before using any feature of the SDK. Initialisation should happen in onCreate() method of your application class - this ensures the Nuclei SDK gets initialised when the user opens the application.

Please follow these steps:

  1. Your Application class should extend the MultiDexApplication class. In case you have a super Application class which you have already extended, then refer Enable multidex for apps 

  2. Create a private instance of NucleiSDK and expose it using a public getter.

  3. Inside the onCreate() method of your application class initialise the Nuclei SDK.

  4. Replace <NUCLEI-SDK-KEY> with the actual key you received from Nuclei.

public class Application extends MultiDexApplication {
private NucleiSDK nucleiSDK;

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

public NucleiSDK getNucleiSDK() {
return nucleiSDK;
}

void initNuclei() {
nucleiSDK = NucleiSDK.bind(this)
// Pass the environment directly (refer to below table)
.setEnvironment(SdkEnvironment.STAGING)
.setKey("<NUCLEI-SDK-KEY>")
.setTheme(R.style.SampleSdkTheme)
.init();

// Notes:
// 1. SampleSdkTheme is same as defined in Step 2 above
// 2. You can set the environment at runtime using build flavour. eg.
// BuildConfig.FLAVOR.equals("production")
// ? SdkEnvironment.INDIA_PRODUCTION
// : SdkEnvironment.STAGING

}

}

Setting the Environment

The setEnvironment() method determines which environment your SDK will connect to. You must choose one of the following environments:

EnvironmentPurpose / Notes
SdkEnvironment.STAGINGPreproduction / UAT testing
SdkEnvironment.INDIA_PRODUCTIONUse for CUG and Production releases in India
SdkEnvironment.UAE_PRODUCTIONUse for Production releases in UAE