Quick start
Table of contents
Use this Quick Start guide to get you up and running with a working AI or live chat hosted by your App.
System Requirements
- Java 8 or higher.
- Gradle 5.3.6 or higher.
- Android Studio.
- The SDK supports devices with API level 16 or higher. (since version 3.5.0)
Set up the SDK on your App.
-
Import SDK dependencies
-
Extra configurations on build.gradle:
Add the following to the
android{...}
block definitionandroid { kotlinOptions { freeCompilerArgs = ['-Xjvm-default=compatibility'] jvmTarget = "1.8" } //overcome the following error: "More than one file was found with OS independent path..." packagingOptions{ pickFirst 'META-INF/atomicfu.kotlin_module' // those may also be needed: pickFirst 'META-INF/main_debug.kotlin_module' pickFirst 'META-INF/main_release.kotlin_module' } }
- If your app is configured with shrink and minify turned on, please read Shrink and Obfuscattion support
👍 Now you are ready to integrate and create some chats.
Create and start a chat
Follow the next steps to create and start a chat.
-
Create an Account
-
Create ChatController
With the ChatController one can create and control multiple chats. The chat type is configured by the Account that is provided on chat creation.
val chatController = ChatController.Builder(context) .build(account, ...) ... // start a new chat, using same chatController: chatController.startChat(account) // restore active chat or starts new chat chatController.restoreChat(fragment?, account?)
-
Add the chat fragment to your activity.
Implement the ChatLoadedListener interface and pass it in the
ChatController.Builder
build method.
Once the chat build succeeded and the fragment is ready to be displayed,onComplete
will be called with the fragment on the result.ChatController.Builder(context).build(account, object : ChatLoadedListener { override fun onComplete(result: ChatLoadResponse) { result.error?.run{ // report Chat load failed } ?: run{ // add result.getFragment() to the applications activity. } } })
Notice
Make sure to activate
ChatController.destruct()
, when the ChatController instance is no longer needed (e.g., Chats UI in app is being closed or the ChatController instance is being replaced). Destruct will verify resources release (including open sockets and communication channels).