ChatInstanceProvider

public final class ChatInstanceProvider implements ChatStateListener, LoggerScope

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
public class Companion
Link copied to clipboard
public interface ConfigurationScope

Configuration scope used to reconfigure and restart the chat session.

Link copied to clipboard
public interface DeviceTokenProvider

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

Link copied to clipboard
public interface Listener

those interested in ChatInstanceProvider updates.

Properties

Link copied to clipboard

Current authorization.

Link copied to clipboard
private final Chat chat

Current chat object.

Link copied to clipboard
private final ChatState chatState

Current chat state.

Link copied to clipboard
Link copied to clipboard

Current configuration.

Link copied to clipboard
private final String customerId

Current optional customerId.

Link copied to clipboard
private final Boolean developmentMode

Current developmentMode state. If true, additional debugging is provided

Link copied to clipboard

Current deviceToken provider.

Link copied to clipboard
private final Logger identity
Link copied to clipboard
private final Logger logger

Current Logger.

Link copied to clipboard
private final String scope
Link copied to clipboard
private final UserName userName

Current user name.

Functions

Link copied to clipboard

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

Link copied to clipboard
public final Unit cancel()

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

Link copied to clipboard
public final Unit close()

Close any connected chat web sockets.

Link copied to clipboard
public final Unit configure(Context context, Function1<ChatInstanceProvider.ConfigurationScope, Unit> actions)

Update the configuration of chat.

Link copied to clipboard
public final Unit connect()

Connect the chat web socket so chat functions are available.

Link copied to clipboard

Current authorization.

Link copied to clipboard
public final Chat getChat()

Current chat object.

Link copied to clipboard
public final ChatState getChatState()
Link copied to clipboard

Current configuration.

Link copied to clipboard
public final String getCustomerId()

Current optional customerId.

Link copied to clipboard
public final Boolean getDevelopmentMode()

Current developmentMode state. If true, additional debugging is provided

Link copied to clipboard

Current deviceToken provider.

Link copied to clipboard
Link copied to clipboard
public final Logger getLogger()

Current Logger.

Link copied to clipboard
public String getScope()
Link copied to clipboard
public final UserName getUserName()

Current user name.

Link copied to clipboard
public Unit log(Level level, String message, Throwable throwable)
Link copied to clipboard

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
public Unit 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
public Unit onReady()

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

Link copied to clipboard

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
public final Unit prepare(Context context, SocketFactoryConfiguration newConfig)
public final Unit prepare(Context context)

Reestablish a chat connection if one does not currently exist.

Link copied to clipboard
@Deprecated(message = "ChatInstanceProvider.reconnect() has been deprecated. Replace with ChatInstanceProvider.connect()", replaceWith = @ReplaceWith(imports = {}, expression = "connect()"))
public final Unit 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
public final Unit setUserName(UserName name)

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
public final Unit signOut()

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