A Android SDK for integrating LiveChat functionality into your mobile application.
LiveChat: https://developers.livechat.com/docs/getting-started/installing-livechat/android-widget/
- Getting started
- Customer information
- Unread message counter
- UI Customization
- Clearing chat session
- Handling links
- Troubleshooting
- Advanced usage
- Migrating from v2.5.0 to 3.0.0
Add real-time customer support to your Android application with LiveChat's native SDK. This guide covers installation, basic setup, and advanced features.
LiveChat SDK is compatible:
Android 5.0 (API level 21) or higher
Java 8 or higher
Follow these steps to integrate LiveChat into your Android application:
Add the JitPack repository to your root build.gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
Add dependency to your app's build.gradle
:
dependencies {
implementation 'com.github.livechat:chat-window-android:3.0.0-rc1'
}
Add Internet permission to AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
Initialize the SDK in the onCreate()
method of your Application
instance
LiveChat.initialize("<LICENSE>", this)
Show the the chat to a customer
LiveChat.getInstance().show()
That's it! Your customer can already start chatting with you.
Pre-fill the pre-chat form and provide customer details to your agents by setting customer information. All information is optional. Group ID defaults to 0 if not provided.
LiveChat.getInstance().setCustomerInfo(
"Joe", // Name
"[email protected]", // Email
"0", // Group ID, defaults to "0"
Collections.singletonMap("internalCustomerId", "ABC123") // Any additional custom parameters
)
Note: You must provide this information before calling
LiveChat.show()
Use com.livechatinc.chatsdk.src.domain.listeners.NewMessageListener
to get notified about new messages in the chat
Set it wherever you want to react on new message, like increase badge count
LiveChat.getInstance().setNewMessageListener()
While chat appearance and language settings are managed through the Agent App, you can customize how errors are displayed to users
You can localize and change the text displayed in the error view by overriding string resources in your app's strings.xml
.
All strings can be found here
To completely change the error view, you can also override the default one by including live_chat_error_layout.xml
in your app's layout resources.
Note: Your custom view must contain a
View
withlive_chat_error_button
id
Activity will follow your activity's theme. To change activity configuration you can just override the activity declaration in your app AndroidManifest.xml
Chat window uses WebView's cookies to store the session. To clear the chat session, you can call:
LiveChat.clearSession()
By default, links sent between your Agents and Customers are opened in the default browser.
If you want to intercept the link and handle it in your app, provide your UrlHandler
LiveChat.getInstance().setUrlHandler(object : UrlHandler {
override fun handleUrl(uri: Uri): Boolean {
// Return true if handled, false to open in default browser
return false
}
})
To monitor and handle issues related to loading the chat view, you can set an error listener. This allows you to capture and respond to errors in a centralized way. Common use cases include reporting errors to analytics platforms or implementing custom error handling logic.
LiveChat.getInstance().setErrorListener { error ->
// Handle the error
}
Configure the logging level to help with debugging and troubleshooting. Set the desired level before initializing LiveChat: Refer to Logger for available log levels.
Logger.setLogLevel(Logger.LogLevel.VERBOSE);
Note: Network calls require at least
INFO
.DEBUG
andVERBOSE
provide maximum level of detail
In case you want to react or track instances where activity for file picking on user device is not found, you can set a listener for this event:
LiveChat.getInstance().setFileChooserNotFoundListener {
Log.e("Example", "File chooser not found. Please check your configuration.")
}
For more control over the SDK integration, consider these advanced options. Note that they require additional implementation steps: If you need to use the following usage, please let us know about your use case. We would love to hear from you!
By default, after LiveChat.show()
the view is inflated and kept in memory. This allows reacting to new messages as described in Unread message counter.
If you don't need that feature and want to free up memory once chat is no longer visible, you can use LiveChatViewLifecycleMode
to control the lifecycle of the view.
You should specify the mode when initializing.
LiveChat.initialize("<LICENSE>", this, LiveChatViewLifecycleMode.WHEN_SHOWN)
Note: Using WHEN_SHOWN mode will disable the
NewMessageListener
no longer works when chat is not visible.
You can directly embed LiveChatView
in your layout, instead of showing it in activity (LiveChat.show()
). This allows you to have more control over the chat window and its placement in your app.
There are additional steps and requirements you need to follow to take full advantage of chat window.
Generally you can refer to LiveChatActivity
for the implementation details, but here is a quick overview of the steps you need to take.
Add <com.livechatinc.chatsdk.LiveChatView />
your layout XML file
During onCreate
of your Activity
or Fragment
call
liveChatView.attachTo(this)
Note: this is required to properly handle the lifecycle of the view, support file sharing and launch links in default external browser
Provide LiveChatViewInitListener
when initializing the view
liveChatView.init(initCallbackListener)
- Kotlin-based SDK
- Streamlined API for easier integration
- Package name changed from com.livechatinc.inappchat to com.livechatinc.chatsdk
- Updated API for initializing and configuring the chat
- Edge-to-edge display support
- Enhanced error handling
dependencies {
implementation 'com.github.livechat:chat-window-android:3.0.0'
}
Note: With version 3 we no longer use "v" prefix
The new API uses LiveChat singleton instead of ChatWindowConfiguration and it's split into two parts: initialization and customer information setup.
Update activity declaration if needed
The old ChatWindowEventsListener
has removed. Some of the callbacks are no longer needed, the rest has been split into individual callbacks
onWindowInitialized()
-> removed for recommended integration. If you're embedding the view directly see Embedding LiveChatView for detailsonChatWindowVisibilityChanged
-> removed recommended integration. If you're embedding the view directly see Embedding LiveChatView for detailsonNewMessage
-> replaced with NewMessageListeneronRequestAudioPermissions
-> removedonError
-> replaced with ErrorListenerhandleUri
-> replaced with UriHandleronFilePickerActivityNotFound
-> FileChooserActivityNotFoundListener
For a complete example of implementation, please refer to the example app included in the repository.
v2 of the library is still available on JitPack. You can find documentation by selecting v2.x.x tag in the repository