YourCX Android SDK - YourCX

YourCX Android SDK

07.10.2024

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.

Installation

The YourCX Android SDK will be available via Maven Central Repository.

Maven Central Repository

To install the SDK using the Maven Central Repository

  • Add mavenCentral to your app's build.gradle repositories block:
repositories {
    mavenCentral()
}
  • Add the package to your dependencies:
dependencies {
  implementation 'io.yourcx.sdk:yourcx-sdk:1.0.0'
}
  • Sync your Android gradle project and the library should be ready to use.

Initialization

  • Configure your 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>
  • Before using any functionalities of the SDK, you must initialize it. This should be done in your 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.

Integration

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.

Targeting survey by screen name

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:

Activity:

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)
    }
}

Fragment:

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)
    }
}

Composable:

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.

Addtional note:

There is also possibility to read the currently supported screen names:

object YourCX {
    fun getSupportedScreens(): Flow<List<String>>
}

Additional parameters

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>>>
}

Inne posty z tej kategorii

WYŚWIETL INNE POSTY

Copyright © 2023. YourCX. All rights reserved — Design by Proformat

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram