You can integrate ASAPP’s Android SDK into your application to provide a seamless messaging experience for your Android customers.

Android Requirements

ASAPP supports Android 5.0 (API level 21) and up. The SDK currently targets API level 30.

ASAPP distributes the library via a Maven repository and you can import it with Gradle. ASAPP wrote the SDK in Kotlin. You can also use it if you developed your application in Java.

Getting Started

To get started with Android SDK, you need to:

  1. Gather Required Information
  2. Install the SDK
  3. Configure the SDK
  4. Open Chat

1. Gather Required Information

Before downloading and installing the SDK, please make sure you have the following information. Contact your Implementation Manager at ASAPP if you have any questions.

App IDAlso known as the “Company Marker”, assigned by ASAPP.
API Host NameThe fully-qualified domain name used by the SDK to communicate with ASAPP’s API. Provided by ASAPP and subject to change based on the stage of implementation.
Region CodeThe ISO 3166-1 alpha-2 code for the region of the implementation, provided by ASAPP.
Supported LanguagesYour app’s supported languages, in order of preference, as an array of language tag strings. Strings can be in the format “{ISO 639-1 Code}-{ISO 3166-1 Code}” or “{ISO 639-1 Code}”, such as “en-us” or “en”. Defaults to [“en”].
Client SecretThis can be an empty or random string* until otherwise notified by ASAPP.
User IdentifierA username or similar value used to identify and authenticate the customer, provided by the Customer Company.
Authentication TokenA password-equivalent value, which may or may not expire, used to authenticate the customer that is provided by the Customer Company.

* In the future, the ASAPP-provided client secret will be a string that authorizes the integrated SDK to call the ASAPP API in production. ASAPP recommends fetching this string from a server and storing it securely using Secure Storage; however, as it is one of many layers of security, you can hard-code the client secret.

2. Install the SDK

ASAPP distributes the library via a Maven repository and you can import it with Gradle. First, add the ASAPP Maven repository to the top-level build.gradle file of your project:

repositories {
    maven {
        url  "https://packages.asapp.com/chat/sdk/android"
    }
}

Then, add the SDK to your application dependencies:

implementation 'com.asapp.chatsdk:chat-sdk:<version>'

Please check the latest Chat SDK version in the repository or release notes.

At this point, sync and rebuild your project to make sure all dependencies are imported successfully. You can also validate the authenticity of the downloaded dependency by following these steps.

Validate Android SDK Authenticity

You can verify the authenticity of the SDK and make sure that ASAPP generated the binary. The GPG signature is the standard way ASAPP handles Java binaries when this is a requirement.

Setup

First, download the ASAPP public key from here.

wget -O asapp_public_key.asc https://docs-sdk.asapp.com/api/chatsdk/android/security/asapp_public.gpg

Verify File Signature

Use the console GPG command to import the key:

gpg --import asapp_public_key.asc

You can verify that the public key was imported via gpg --list-keys.

Download the ASC file directly from our repository. Finally, you can verify the Chat SDK AAR and associated ASC files like so:

gpg --verify chat-sdk-<version>.aar.asc chat-sdk-<version>.aar

3. Configure the SDK

Use the code below to create a configuration, and initialize the SDK with it. You must pass your Application instance.

Refer to the aforementioned required information. ASAPP recommends you initialize the SDK in your Application.onCreate.

import com.asapp.chatsdk.ASAPP
import com.asapp.chatsdk.ASAPPConfig
val asappConfig = ASAPPConfig(
   appId = "my-app-id",
   apiHostName = "my-hostname.test.asapp.com",
   clientSecret = "my-secret")
ASAPP.init(application = this, config = asappConfig)

The SDK should only be initialized once and it is possible to update the configuration at runtime.

4. Open Chat

Once the SDK has been configured and initialized, you can open chat. To do so, use the openChat(context: Context) function which will start a new Activity:

ASAPP.instance.openChat(context = this)

Once the chat interface is open, you should see an initial state similar to the one below:

Next Steps

Was this page helpful?