Integration Guide
Prerequisites
The ForterSDK requires initialization from your application's main context. If you haven't set up an Application class yet:
- Create an Application class
Integration Steps
1. Initialize the SDK
Add the following initialization code to your Application class's onCreate() method:
// Get ForterSDK instance and initiate it with the application context
IForterSDK ftr = ForterSDK.getInstance();
ftr.init(this, AppConstants.FORTER_SITE_ID);You will need to provide a valid Forter site ID (please use the test site ID only for debugging purposes)
Advanced configuration of the SDK can be done by initializing the SDK with a customized ForterSDKConfiguration. Please consult with your Forter Implementation Engineer before changing the default configuration.
2. Register Activity Lifecycle Callbacks
After initializing the SDK in the onCreate() method of your application class, please register our built-in activity lifecycle callbacks:
This step is only required for SDK versions below 3.0.0.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
registerActivityLifecycleCallbacks(ftr.getActivityLifecycleCallbacks());
}Complete Integration Example
After performing the above steps, here's how your onCreate() method should look:
@Override
public void onCreate() {
super.onCreate();
String mobileId = ForterIntegrationUtils.getDeviceUID(this);
// Get ForterClient instance and initiate it
IForterSDK ftr = ForterSDK.getInstance();
ftr.init(this,
AppConstants.FORTER_SITE_ID // your unique Forter site ID
);
// Start generic activity-based navigation tracking (ForterSDK < 3.0.0)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
registerActivityLifecycleCallbacks(ftr.getActivityLifecycleCallbacks());
}
}