ChatInstanceProvider

ChatRepository owns and maintains the chat object and its state.

Parameters

configuration

Initial Sdk Configuration to use.

authorization

Initial authorization to use.

userName

Initial user name to use.

developmentMode

True if in development mode to get extra logging.

deviceTokenProvider

Provider of device tokens for push messages, default implementation will disable push notifications.

logger

The Logger used by the SDK, default is no-op implementation.

customerId

Optional customerId of the user.

chatBuilderProvider

INTERNAL USAGE ONLY Provides ChatBuilder. For internal testing usage only.

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Configuration scope used to reconfigure and restart the chat session.

Link copied to clipboard
fun interface DeviceTokenProvider

Defines provider of device token for push notifications, typically this will be Firebase.messaging.token.

Link copied to clipboard
interface Listener

those interested in ChatInstanceProvider updates.

Properties

Link copied to clipboard

Current authorization.

Link copied to clipboard
var chat: Chat?

Current chat object.

Link copied to clipboard

Current chat state.

Link copied to clipboard

Current configuration.

Link copied to clipboard

Current optional customerId.

Link copied to clipboard

Current developmentMode state. If true, additional debugging is provided

Link copied to clipboard
Link copied to clipboard
open override val identity: Logger
Link copied to clipboard

Current Logger.

Link copied to clipboard
open override val scope: String
Link copied to clipboard

Current user name.

Functions

Link copied to clipboard

Add a listener to receive notifications of chat and state changes.

Link copied to clipboard
fun cancel()

Cancel any pending prepare or connect action and return the state to an appropriate starting point.

Link copied to clipboard
fun close()

Close any connected chat web sockets.

Link copied to clipboard

Update the configuration of chat.

Link copied to clipboard
fun connect()

Connect the chat web socket so chat functions are available.

Link copied to clipboard
open override fun log(level: Level, message: String, throwable: Throwable?)
Link copied to clipboard
open override fun onChatRuntimeException(exception: RuntimeChatException)

Method is invoked when Chat instance encounters possible exception in a background process. Application should handle these exceptions according to the description of each RuntimeChatException. Some of these exceptions can indicate issues during transfer of messages while others may indicate that further interactions with Chat will be ignored.

Link copied to clipboard
open override fun onConnected()

Method is invoked when chat instance is connected and ready to send/receive messages, events or actions. This happens once initial connection is established or after Chat.reconnect is called.

Link copied to clipboard
open override fun onReady()

Method is invoked when chat instance has finished performing background tasks after connection was established.

Link copied to clipboard
open override fun onUnexpectedDisconnect()

Method is invoked when chat session is unexpectedly lost. Chat instance should be considered unusable, until reconnect is performed. If this method is invoked while the Chat.reconnect is being performed, then application should consider the reconnection attempt as failed. It is recommended that only a limited number of reconnection attempts are performed. If the problems persist despite the fact that the device has internet connectivity, then please collect logs (assuming the development mode is enabled) and contact your CXone representative with request for support. Integration should also check for possibly lost incoming messages & thread changes once reconnection is done.

Link copied to clipboard
fun prepare(context: Context, newConfig: SocketFactoryConfiguration? = null)

Reestablish a chat connection if one does not currently exist.

Link copied to clipboard
fun reconnect()

Reconnect a broken connection.

Link copied to clipboard

Remove a listener no longer concerned with chat and state changes.

Link copied to clipboard

Set custom values on the current chat instance.

Link copied to clipboard

Sets UserName which will be used during creation of Chat instance and will apply it to current instance of Chat, if it exists. The username will be applied only if the chat channel configuration allows it.

Link copied to clipboard
fun signOut()

Sign out/terminate the chat connection and clear any saved credentials.