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)
.setEnvironment(SdkEnvironment.STAGING)
.enableLogs(true) // BuildConfig.DEBUG
.setBaseUrl(baseUrl)
.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.PRODUCTION
// : SdkEnvironment.STAGING

}

}

Note:

baseUrl should be set to below values based on whether you want the Nuclei SDK to point to preproduction or production apis respectively:

String PRE_PROD_BASE_URL = "preprod-az.gonuclei.com/";
String PROD_BASE_URL = "production-az.gonuclei.com/";