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:
- Open your app’s
build.gradle.kts
file and add the following dependencies to get the latest version of our SDK:
- To access our SDK, hosted on mavenCentral, add it to your root’s
build.gradle.kts
file.
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
-
In DevRev, go to Settings > Support > PLuG Tokens through the settings icon in the top-left corner.
-
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.
-
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.
- To configure the SDK, invoke the following method inside your
Application
class:
- If you don’t have a custom
Application
class, create one as shown below:
-
In the
onCreate
method of your application, configure the DevRev SDK using the credentials obtained earlier. -
Ensure that the custom application is specified in the
AndroidManifest.xml
, as shown below:
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:
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:
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:
The support button accepts default parameters like:
or
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 theshowSupport()
function or XML button. -
Issue: Incorrect operation due to
App ID
andsecret
misconfiguration.
Solution: Ensure correct functionality by double-checking that bothApp ID
andsecret
values are accurately configured in your application or sample app.