NowChatSdkCallbacks interface - Android
The NowChatSdkCallbacks interface provides functions that enable callbacks for host applications to configure or handle actions from the NowChatSDK.
| Name | Type | Description |
|---|---|---|
| isFileCollectionBlocked | Boolean | Flag that indicates whether the host application should prevent NowChat from
opening the file picker. Valid values:
|
| isGalleryCollectionBlocked | Boolean | Flag that indicates whether the host application should prevent NowChat from
opening the photo gallery. Valid values:
|
| isLocationCollectionBlocked | Boolean | Flag that indicates whether the host application should prevent NowChat from
accessing geolocation positioning. Valid values:
|
| isPhotoCollection Blocked | Boolean | Flag that indicates whether the host application should prevent NowChat from
accessing the camera. Valid values:
|
NowChatSdkCallbacks - didEndSessionWithId(sessionId: String)
Called when the chat screen is closed and the chat session ends.
| Name | Type | Description |
|---|---|---|
| sessionId | String | Sys_id of the session that ended. Table: Conversation Session [sys_cs_session] |
| Type | Description |
|---|---|
| None |
The following code example shows where to place your code to override the default functionality.
class SampleNowChatSDKCallbacks : NowChatSdkCallbacks {
override fun didEndSessionWithId(sessionId: String) {
Log.i("NowChat", "Chat session $sessionId ended.")
}
//override other methods
}
NowChatSdkCallbacks - loadUri(uri: Uri, context: Context)
Handles the specified URI, such as to open it in a webview, custom tab, or external browser.
| Name | Type | Description |
|---|---|---|
| uri | Uri | URI to open. |
| context | Context | Application context. |
| Type | Description |
|---|---|
| None |
The following code example shows how to call this function.
class SampleNowChatSDKCallbacks : NowChatSdkCallbacks {
override fun loadUri(uri: Uri, context: Context) {
// Open the uri in a webview
val webview = WebView(context)
webview.loadUrl(uri.toString())
}
// Override other methods
}
NowChatSdkCallbacks - onExit(exitCode: NowChatExitCode)
Sets the result code to return when NowChat is exited.
This callback gets called when that full screen chat is closed and the user is returned back to the host application.
| Name | Type | Description |
|---|---|---|
| exitCode | NowChatExitCode | Reason for exiting NowChat. Valid values:
|
| Type | Description |
|---|---|
| None |
The following code example shows how to call this function.
class SampleNowChatSDKCallbacks : NowChatSdkCallbacks {
override fun onExit(exitCode: NowChatExitCode) {
when (exitCode) {
NowChatExitCode.UserExit -> Log.i("NowChat", "User exited using the up button or back button")
NowChatExitCode.SessionInitializationError -> Log.i("NowChat", "Unable to initialize session with instance")
NowChatExitCode.ChatPluginNotInstalledError -> Log.i("NowChat", " Chat plugin not installed on instance.")
NowChatExitCode.Unknown -> Log.i("NowChat", "User exited for Unknown reason")
}
}
// Override other methods
}
NowChatSdkCallbacks - provideProgressView(context: Context)
Returns the view to display when the NowChat UI data is loading; typically a configured indeterminate progress bar.
| Name | Type | Description |
|---|---|---|
| context | Context | Application context to use to create the view. |
| Type | Description |
|---|---|
| View | View that the NowChat service uses when loading. |
The following code example shows how to call this function.
class SampleNowChatSDKCallbacks : NowChatSdkCallbacks {
override fun provideProgressView(context: Context): View? {
return ProgressBar(context).apply {
indeterminateTintList = ColorStateList.valueOf(
MaterialColors.getColor(
context,
android.R.attr.colorPrimary,
Color.BLACK)
)
}
// Override other methods
}
}