Android SDK
Overview
Real-time CDP offers an Android SDK that enables you to track user behavior, capture clickstream events, enrich customer profiles, and deliver personalized experiences such as push notifications and In-App Notifications.
The SDK integrates directly into your application and sends structured event data to rCDP in real time. This ensures that mobile data is unified with web and backend data for a complete customer view.
How It Works
-
Add the SDK to your Android project
-
Configure dependencies and permissions
-
Initialize the SDK during application launch
-
Capture user interactions and events
-
Send data to rCDP for processing and activation
SDK Integration Flow
-
SDK Installation
-
SDK Integration
-
SDK Initialization
-
SDK Methods
Follow these steps to successfully integrate and use the SDK within your Android application. :contentReference[oaicite:0]{index=0}
SDK Installation
Add dependency from the catalog to the application. Once the catalog is added, include the SDK dependency as shown below.
Add TargetOneMobileSDK.aar file in the libs folder in your project.
dependencies {
implementation files('libs/TargetOneMobileSDK.aar')
}
SDK Integration
Follow the steps below to integrate the SDK into your Android application.
Step 1: Add Dependencies
dependencies {
implementation 'com.android.support:cardview-v7:27.1.1-alpha1'
implementation 'com.github.bumptech.glide:glide:3.6.1'
implementation 'com.google.code.gson:gson:2.4'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-messaging:18.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.android.support:support-v4:27.1.1'
}
Step 2: Enable MultiDex
android {
defaultConfig {
multiDexEnabled true
}
}
Step 3: Add Google Services Plugin
apply plugin: 'com.google.gms.google-services'
Step 4: Configure Firebase
Add the google-services.json file to your project to enable push notifications.
Step 5: Update Manifest
Add the Firebase messaging service in your AndroidManifest.xml file to enable push notification handling.
<service android:name="com.manthan.targetone.service.MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
Step 6: Add Permissions
Add the required permissions in your AndroidManifest.xml file.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
SDK Initialization
Initialize the SDK during application launch to start tracking events and user interactions.
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
context = this;
TargetOneSDKContext targetOneSDKContext = new TargetOneSDKContext();
targetOneSDKContext.shortcorrtime = 1800000l;
targetOneSDKContext.enableNotification = true;
targetOneSDKContext.enableLocation = true;
targetOneSDKContext.urlPrefix = "sandbox/rcdp-app2";
targetOneSDKContext.tenantHash = "TENANT_HASH";
targetOneSDKContext.accessToken = "ACCESS_TOKEN";
TargetOneMobileSDK.getInstance().init(context, targetOneSDKContext);
}
Configuration Details
tenantHash: Unique tenant identifier
accessToken: Authentication token
urlPrefix: Endpoint configuration
enableNotification: Enables push notifications
enableLocation: Enables location tracking
Handling Runtime Permissions
Use the following method to handle runtime permission responses:
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
@NonNull int[] grantResults) {
switch (requestCode) {
case 2: {
TargetOneMobileSDK.getInstance().onRequestPermissionsResult(
context, requestCode, permissions, grantResults
);
}
}
}
Handling Activity Results
Use the following method to handle activity results required by the SDK:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case 1: {
TargetOneMobileSDK.getInstance().onActivityResult(
context, requestCode, resultCode, data
);
break;
}
}
}
SDK Methods
The Android SDK provides a set of core methods that enable you to capture user behavior, manage customer data, and deliver real-time engagement experiences within your application.
These methods form the foundation of your integration and allow you to track user interactions, build unified customer profiles, and trigger contextual messaging.
The key SDK methods supported are:
Customer Profiles – Create, update, and manage user identity and attributes
Clickstream Events – Capture user interactions and behavioral events in real time
In-App Notifications – Deliver personalized messages within the application
Customer Profiles
Customer customer = new Customer();
customer.setCustomerCode("12345");
customer.setEmail("abc@gmail.com");
customer.setMobileNo("4544454445");
TargetOneMobileSDK.getInstance().setCustomerProfile(context, customer);
Clickstream Events
TargetOneMobileSDK.getInstance().sendClickStream(context, eventType, eventData, (APIResponseInterface)this);
Handle API Response
Use the following APIResponseInterface method to enable API response callback.
@Override
public void onCallback(int statusCode, JSONObject jsonObject) {
/* Here statusCode refers to StatusCode of API Response
&
jsonObject refers to JSONObject Response for realtime API
*/
}
In-App Notifications
In-App Notifications are configured from the dashboard and displayed automatically by the SDK.
Block In-App Notifications
TargetOneSDKContext.blockInApp.add(String ActivityName);
Send FCM Token
public void onNewToken(String s) {
TargetOneMobileSDK.getInstance().registerFcmToken(getApplicationContext(), s);
}
Handle Push Notifications
if (!TargetOneMobileSDK.getInstance().handleFcmNotification(getApplicationContext(), remoteMessage))
{
Log.v(TAG, "Notification Not From TargetOne");
}
Best Practices
Initialize the SDK early
Set customer profile after login
Validate event data
Test on real devices
Ensure Firebase configuration is correct