The YourCX Android SDK provides a seamless integration for managing and displaying surveys within your Android application. This document covers installation, initialization and available API for using the SDK effectively.
The YourCX Android SDK will be available via Maven Central Repository.
To install the SDK using the Maven Central Repository
mavenCentral
to your app's build.gradle
repositories block:repositories {
mavenCentral()
}
dependencies {
implementation 'io.yourcx.sdk:yourcx-sdk:1.0.0'
}
API key
and client id
in AndroidManifest.xml
:<Application>
<!-- ... -->
<meta-data android:name="io.yourcx.yourcx_android_sdk.api_key" android:value="<api_key>"/>
<meta-data android:name="io.yourcx.yourcx_android_sdk.client_id" android:value="<client_id>" />
</Application>
Application
class.class YourApplication: Application() {
override fun onCreate() {
super.onCreate()
YourCX.initialize(this)
}
}
Please note that if you use any SDK method before initializing, the IllegalStateException
will be thrown.
YourCX enables you to deploy highly targeted surveys within your app. Through the YourCX dashboard, you can configure specific conditions groups that must be fulfilled for surveys to be displayer. When the app state meet the conditions set in the YourCX panel, the survey will automatically appear on the screen.
In YourCX dashboard you will be able to specify a list of screens that SDK will take into consideration when deciding whether the survey should be displayed. YourCX SDK recognizes the screen by it's ID. To set it up in the application, you need to tell the SDK when the user enters and leaves the screen:
class ActivityA : Activity() {
val SCREEN_NAME = "ScreenID"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// ...
YourCX.enterScreen(SCREEN_NAME)
}
override fun onDestroy() {
super.onDestroy()
YourCX.leaveScreen(SCREEN_NAME)
}
}
class FragmentA : Fragment() {
val SCREEN_NAME = "ScreenID"
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// ...
YourCX.enterScreen(SCREEN_NAME)
}
override fun onDestroyView() {
super.onDestroyView()
YourCX.leaveScreen(SCREEN_NAME)
}
}
const val SCREEN_NAME = "ScreenID"
@Composable
fun ScreenA() {
LaunchedEffect(Unit) {
YourCX.enterScreen(SCREEN_NAME)
}
DisposableEffect(Unit) {
onDispose {
YourCX.leaveScreen(SCREEN_NAME)
}
}
}
Note: SCREEN_NAME is case-sensitive. If there is any discrepancy between the screen IDs used in the app and those declared in the YourCX Panel, the SDK will not recognize those screens, and the survey will not appear.
There is also possibility to read the currently supported screen names:
object YourCX {
fun getSupportedScreens(): Flow<List<String>>
}
In addition to visiting screens, YourCX SDK offers an option to provide additional parameters to be checked as a condition to display a survey. In order to add parameter, use:
object YourCX {
fun addAdditionalParam(key: String, value: List<String>)
}
It is also possible to read currently set parameters:
object YourCX {
fun getAdditionalParams(): Flow<Map<String, List<String>>>
}
Copyright © 2023. YourCX. All rights reserved — Design by Proformat