This README provides guidance on integrating the Zoom Virtual Agent Web SDK for Android, handling JavaScript callbacks, passing environment parameters, managing WebView scenarios, and processing download requests.
- Android 6.0 (API level 23) or later
- Android Studio Hedgehog | 2023.1.1 or later
- Basic knowledge of Java or Kotlin
Clone the sample app repository from GitHub to your local machine, then open the project in Android Studio.
Before running the app, you need to configure it with the required parameters.
- Navigate to the Campaign Management tab on the contact center management page.
- Select a campaign, go to the settings tab, and find the "Full-page chat URL" section.
- Click "Generate" to create the URL.
To integrate on Android, support essential JavaScript functions and handle JavaScript native callback events in the MainJavaActivity
or MainKotlinActivity
.
You can either:
- Use the core code provided in this document and integrate it into your project.
- Utilize the provided sample project on GitHub, available in both Java and Kotlin.
Example Classes:
- Java:
MainJavaActivity.java
- Kotlin:
MainKotlinActivity.kt
// JSON data to be injected into the WebView as JavaScript
private const val JSON_DATA = """
window.zoomCampaignSdkConfig = window.zoomCampaignSdkConfig || {
language: 'user language',
firstName: 'user first name',
lastName: 'user last name',
nickName: 'user nick name',
address: 'user address',
company: 'user company',
email: 'user email',
phoneNumber: 'user phone number'
};
"
// Inject JSON data as JavaScript into the WebView when the URL is loaded
private fun injectJsonDataFunction() {
val js = "javascript: \$JSON_DATA;"
binding.webView.loadUrl(js)
}
// Inject JavaScript handler functions into the WebView when the URL is loaded
private fun injectJavaScriptFunction() {
val js = """
javascript: window.addEventListener('zoomCampaignSdk:ready', () => {
if (window.zoomCampaignSdk) {
window.zoomCampaignSdk.native = {
exitHandler: {
handle: function() {
\$EXIT_HANDLER_NAME.handleExit();
}
},
commonHandler: {
handle: function(e) {
\$COMMON_HANDLER_NAME.handleCommon(JSON.stringify(e));
}
}
};
}
});
"""
binding.webView.loadUrl(js)
}
// JavaScript interface method to handle exit commands
@JavascriptInterface
fun handleExit() {
// Your code
}
// Inject handleHandoff function into the WebView when the URL is loaded
private fun injectHandoffFunction() {
val js = """
javascript: window.addEventListener('support_handoff', (e) => {
\$SUPPORT_HANDOFF_HANDLER_NAME.handleHandoff(JSON.stringify(e.detail));
});
"""
binding.webView.loadUrl(js)
}
// JavaScript interface method to handle handoff commands
@JavascriptInterface
fun handleHandoff(e: String?) {
// Your code
}
Embed a customer's website in the Android WebView with links utilizing the ZVA WebSDK. Since JavaScript callback events are handled by the customer’s website, no additional native code is needed on Android.
Trigger native events to open the WebView displaying the Web Chat window. In this scenario, native code needs to handle JavaScript events received from the WebView.
- Case 1: Close Web Chat View
Handle the callback event inMainJavaActivity
orMainKotlinActivity
, and close the current native web view window. - Case 2: Pass Native Parameters to Web Chat
Pass parameters from the native app to the WebView context when opening a chat window. - Case 3: Open URL in the Current WebView (In-App)
Handle navigation actions within the current WebView. - Case 4: Open URL in System Browser
Open URLs from the WebView in the system browser. - Case 5: Open URL in new CustomTabs (In-App)
Use the internal browser intents, such as CustomTabs, to open the ZVA Web SDK URL in the Android app. - Case 6: Dispatch Support Handoff Event
Use JavaScript's handoff event to pass data from the web to the Android native app.
For a detailed integration guide, please refer to the Zoom Virtual Agent Web SDK Documentation.