SDKsPLuG SDK

Integrate PLuG with your Android app

This guide will help you to integrate PLuG using DevRev SDK with your Android app.

Requirements

  • Android Studio 2022.1.1
  • Android Gradle plugin version 7.4
  • Gradle version 7.6
  • Minimum Android SDK 29

Setup

To integrate the latest version of our SDK into your app, follow these steps:

  1. Open your app’s build.gradle.kts file and add the following dependencies to get the latest version of our SDK:
1dependencies {
2 implementation("ai.devrev.sdk:core:<version>")
3}
  1. To access our SDK, hosted on mavenCentral, add it to your root’s build.gradle.kts file.
1repositories {
2 mavenCentral()
3}

After completing these steps in your build.gradle.kts script, you should be able to import and use the DevRev SDK in your Android application.

Setting up the DevRev SDK

Obtain credentials

  1. In DevRev, go to Settings > Support > PLuG Tokens through the settings icon in the top-left corner.

  2. Under the App Credentials section, generate the necessary credentials for SDK usage. Remember to save both the App ID and App Secret as they are required in SDK configuration.

  3. Acquire the Your Unique App ID (referred to as supportID in the code) by visiting the PLuG Settings page.

Initialization

After you’ve obtained the necessary credentials, proceed to configure the DevRev SDK within your app.

  1. To configure the SDK, invoke the following method inside your Application class:
1fun DevRev.configure(
2 context: Context,
3 appID: String,
4 secret: String,
5 supportId: String
6)
  1. If you don’t have a custom Application class, create one as shown below:
1import ai.devrev.sdk.DevRev
2
3class FooApplication : Application() {
4
5 override fun onCreate() {
6 super.onCreate()
7 DevRev.configure(
8 context = this,
9 appId = "<APP_ID>",
10 secret = "<SECRET>",
11 supportId = "<SUPPORT_ID>",
12 )
13 }
14}
  1. In the onCreate method of your application, configure the DevRev SDK using the credentials obtained earlier.

  2. Ensure that the custom application is specified in the AndroidManifest.xml, as shown below:

<application
android:name=".FooApplication">
</application>

User identification

Before initiating the chat feature, user identification is required. Mobile applications can submit various arguments to identify the user. The following example adopts a simplistic approach, providing the minimum required arguments for successful user identification:

1DevRev.identify(
2 userIdentification = UserIdentification(userId = "foo@example.org")
3)

Upon completing user identification, the chat dialog (conversations) supported by the DevRev SDK becomes accessible.

To open the chat dialog, the application should utilize the showSupport API, as shown below:

1DevRev.showSupport(context: Context)

Support button

The mobile SDK also offers a support button that can be integrated into your application. To include it on the current screen, add the following code to your XML layout:

<ai.devrev.sdk..view.FloatingActionButton
android:id="@+id/_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

The support button accepts default parameters like:

1android:src="@your_drawable_here"

or

1android:backgroundTint="@your_background_color"

This allows customization according to your preferences. The button appears on your screen.

At this stage, you should be able to run the app and leverage all the features of the DevRev SDK. Clicking the Support button navigates the user to the chat interface.

Sample app

The examples presented in this document are taken from the DevRev SDK sample app. The sample app showcases both functional and XML implementations and is included as part of the repository. It’s recommended to run the sample app before integrating the SDK into your target application.

Troubleshooting

  • Issue: Encountering problems with DevRev SDK integration.
    Solution: Verify the correct SDK dependency setup in the project. Ensure mavenCentral is accessible from the IDE, and confirm accurate detection of the selected DevRev PLuG SDK version.

  • Issue: The showSupport() function or XML button is unresponsive.
    Solution: Confirm that user identification is performed before using the showSupport() function or XML button.

  • Issue: Incorrect operation due to App ID and secret misconfiguration.
    Solution: Ensure correct functionality by double-checking that both App ID and secret values are accurately configured in your application or sample app.