SDK Integration

This document provides steps for integrating your Android app with Hackle via the Hackle SDK for Andriod platforms. SDK Integration is a must in order to use the functions of a Hackle SDK.

Step 1: Add Dependencies

Think of this step as importing our SDK into your codebase. To use our Hackle services add the following dependency code and import our SDK.

repositories {
  mavenCentral()
}

dependencies {
  implementation 'io.hackle:hackle-android-sdk:2.6.1'
}

ProGuard / R8

If you are using ProGuard, R8, the obfuscation rules are automatically included in the aar artifact. If this is not the case, you should also include the rule below.

-keep class io.hackle.android.** { *; }
-keep class io.hackle.sdk.** { *; }

Step 2: Initialize the SDK

Once you have imported the dependencies, in order to start using the Hackle SDK you must initialize the SDK. During this step, we get the information needed for SDK integration from the Hackle Server and store it in the SDK. As this operation runs asynchronously, the callback action lets you know that the initialization is complete.

Initialize the SDK by passing the SDK key and callback to the HackleApp.initializeApp() method.

The SDK key can be found in the SDK integration in the dashboard of Hackle service.

// Enter the SDK Key in the YOUR_APP_SDK_KEY. 
HackleApp.initializeApp(getApplicationContext(), YOUR_APP_SDK_KEY, () -> {
  // SDK ready to use.
});
// Enter the SDK Key in the YOUR_APP_SDK_KEY. 
Hackle.initialize(applicationContext, YOUR_APP_SDK_KEY) {
  // SDK ready to use.
}

🚧

SDK initialization should only occur once

The HackleApp.initializeApp() method must only be called once.
It is recommended to initialize the SDK in the onCreate() method of the Application instance.

Recommended initialization method: initialize via loading screen

Instead of starting the app immediately, display a loading screen and initialize the SDK.
The callback then closes the loading screen and allows the user to start interacting with the app.

If you're using this method, it's a good idea to put a time limit on the loading screen.

After initialization, you can obtain the HackleApp instance through the code below.

HackleApp hackleApp = HackleApp.getInstance();
val hackleApp = Hackle.app