Integration steps
Step 1: Installation
- Download the Contlo Android SDK from the link contlo-androidSDK.aar
- Import the .aar file to your app/libs folder
- Add the following line to your app-level build.gradle file
dependencies {
implementation files('libs/contlo-androidSDK.aar')
}
Step 2: Add Contlo API_KEY
Add your API-KEY in your AndroidManifest.xml file as a meta-data tag like this:
<application>
<meta-data
android:name="contlo_api_key"
android:value="YOUR_API_KEY" />
</application>
- You can find your API KEY in your Contlo Dashboard in the Settings section under the API Tab
- Make sure to use "contlo_api_key" as the android:name value for the meta data tag
Step 3: Add required dependencies
Import these dependencies in your app-level build.gradle file:
dependencies {
implementation 'com.google.android.gms:play-services-tasks:18.0.2'
implementation 'com.google.firebase:firebase-messaging:23.1.2'
}
Initialise the SDK
In the onCreate() method of your launcher activity or your application class, call the following function:
import com.contlo.androidsdk.ContloSDK
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
//Call this function before any other code in your onCreate method
val contloSDK = ContloSDK()
contloSDK.init(applicationContext)
}
Permissions:
Standard Permissions:
- Add these Permissions in your AndroidManifest.xml file:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_PACKAGE_SIZE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Advertising Id Tracking:
-
Advertising Id Tracking - If you want to track anonymous users across devices, you can enable tracking of Advertising Id. This will set the Advertising ID as a Profile Property in the contact details under the Audience Section in your Contlo dashboard. Follow the below steps:
-
Add the following permission in your AndroidManifest.xml file:
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
Note You need to explicitly ask your user for their consent to track Advertising ID as per GDPR Compliance rules. In your app codebase, if the user provides consent to track Ad Id, call the following function:
import com.contlo.androidsdk.ContloSDK
val contloSDK = ContloSDK(applicationcontext)
//Call this function when user provides consent
contloSDK.trackAdId(true)
//Call this function when user denies or revokes consent
contloSDK.trackAdId(false)
Verify Integration:
After initializing the SDK according to the above steps, open the app on a device or emulator. You will see a new Anonymous user is created on your Contlo dashboard. This means that you have successfully integrated the Contlo Android SDK.
Welcome aboard!!