Class ZopimChatApi
- java.lang.Object
-
- com.zopim.android.sdk.api.ZopimChatApi
-
- All Implemented Interfaces:
- ChatApi, ChatApiCommands, ChatSession
public abstract class ZopimChatApi extends java.lang.Object implements ChatApi, ChatSession
Definition for initialization and configuration of the chat.Firstly, to initialize the chat call
ZopimChatApi.init(String)
with the correct account key obtained at your Zopim account configuration page.A global chat configuration can be provided at initialization which will apply to all chat sessions that get started. Additionally, each chat session can be configured separately during chat start
ZopimChatApi#start(android.support.v4.app.FragmentActivity)
. Starting a chat will provide an instance ofChatApi
used for chat communication. That chat is the bound to the lifecycle of the activity that was used to start the chat.- See Also:
- Getting Started,
ChatApi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static class
ZopimChatApi.DefaultConfig<T extends ZopimChatApi.DefaultConfig>
Configuration class for global chat configurationstatic class
ZopimChatApi.SessionConfig<T extends ZopimChatApi.SessionConfig>
Configuration class for session chat configuration
-
Field Summary
-
Fields inherited from interface com.zopim.android.sdk.api.ChatSession
ACTION_CHAT_APP_BACKGROUND, ACTION_CHAT_APP_FOREGROUND, ACTION_CHAT_BACKGROUND, ACTION_CHAT_FOREGROUND, ACTION_CHAT_INITIALIZATION_TIMEOUT, ACTION_CHAT_SESSION_TIMEOUT, DEFAULT_CHAT_INITIALIZATION_TIMEOUT, DEFAULT_CHAT_SESSION_TIMEOUT, DEFAULT_RECONNECT_TIMEOUT
-
-
Constructor Summary
Constructors Constructor and Description ZopimChatApi()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static void
clearPushToken()
Clear the token so that push notifications are no longer sent for agent chat messages.static DataSource
getDataSource()
Gets chat data source defined inDataSource
andPathDataSource
static java.lang.Long
getInitializationTimeout()
Gets initialization timeout that was configured viaZopimChatApi.DefaultConfig.initializationTimeout
If timeout was not configured it will return theChatSession.DEFAULT_CHAT_INITIALIZATION_TIMEOUT
static java.lang.String
getPushToken()
Get the push tokenstatic java.lang.Long
getReconnectTimeout()
Gets reconnect timeout that was configured viaZopimChatApi.DefaultConfig.reconnectTimeout
If timeout was not configured it will return theChatSession.DEFAULT_RECONNECT_TIMEOUT
static ZopimChatApi.DefaultConfig
init(java.lang.String accountKey)
Initiates chat and returnsZopimChatApi.DefaultConfig
configuration builder to be used for configuring the global chat settings.static void
onMessageReceived(PushData pushData)
Notify the SDK of FCM message receipt.static void
resetIdentity()
Resets the identity to a new anonymous visitor.static ChatApi
resume(FragmentActivity activity)
Attempts to resume the existing chat if possible.static void
setPushToken(java.lang.String token)
Set the push token to allow agent message to be sent to the app via push notifications.static void
setVisitorInfo(VisitorInfo visitorInfo)
Configures the globalVisitorInfo
static ChatApi
start(FragmentActivity activity)
Starts the chat withZopimChatApi.DefaultConfig
global configuration.static void
trackEvent(java.lang.String description)
Leaves an event trace.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.zopim.android.sdk.api.ChatApi
getConfig, hasEnded, resetTimeout
-
Methods inherited from interface com.zopim.android.sdk.api.ChatApiCommands
addNote, disconnect, emailTranscript, endChat, resend, send, send, sendChatComment, sendChatRating, sendOfflineMessage, setDepartment, setEmail, setName, setNote, setPhoneNumber
-
-
-
-
Method Detail
-
resetIdentity
public static void resetIdentity()
Resets the identity to a new anonymous visitor.Calling this method will end any current ongoing chat, clear the cache and erase all locally stored information.
You can call this method prior to starting another chat with
ZopimChatApi.start(FragmentActivity)
to ensure the new chat is associated with a new visitor.
-
init
public static ZopimChatApi.DefaultConfig init(java.lang.String accountKey)
Initiates chat and returnsZopimChatApi.DefaultConfig
configuration builder to be used for configuring the global chat settings. This configuration will apply to all new instances of a chat session unless a new session configuration is provided when starting the new chat.- Parameters:
accountKey
- Your account key obtained from the Zopim widget config page. Will configure chat to use your Zopim instance.- Returns:
- configuration builder for setting the global chat configuration
-
start
public static ChatApi start(FragmentActivity activity)
Starts the chat withZopimChatApi.DefaultConfig
global configuration. Chat needs to be previously initialized.- Parameters:
activity
- that holds the chat session- Returns:
- chat session instance
-
resume
public static ChatApi resume(FragmentActivity activity)
Attempts to resume the existing chat if possible. Chat needs to be previously initialized.Resuming a chat will be possible if the previous chat was not ended via
ChatApiCommands.endChat()
or expired. Chat timeout time, defined hereChatSession.DEFAULT_CHAT_SESSION_TIMEOUT
is the time that expired after the last message exchange. If resuming was successful it will restore chat configuration from the server. If chat can not be resumed this will still return the chat instance but it won't be able to chat because it has endedChatApi.hasEnded()
.Resumed chat might not be immediately ready to communicate.
- Parameters:
activity
- that holds the chat session- Returns:
- chat session instance
-
getDataSource
public static DataSource getDataSource()
Gets chat data source defined inDataSource
andPathDataSource
Data source provides subscription to data update broadcasts. It also enables to get current state of a data path.
- Returns:
- data source
-
setVisitorInfo
public static void setVisitorInfo(VisitorInfo visitorInfo)
Configures the globalVisitorInfo
Visitor info can be set at any point, but the changes will take effect at next chat session start
- Parameters:
visitorInfo
- visitor data fromVisitorInfo
-
trackEvent
public static void trackEvent(java.lang.String description)
Leaves an event trace.It is possible to track event prior chat session being started. Tracked events will be sent as soon as chat session is connected and any further event after that point will be sent immediately.
- Parameters:
description
- of the event
-
setPushToken
public static void setPushToken(java.lang.String token)
Set the push token to allow agent message to be sent to the app via push notifications.- Parameters:
token
- the token received from FCM
-
clearPushToken
public static void clearPushToken()
Clear the token so that push notifications are no longer sent for agent chat messages.
-
getPushToken
public static java.lang.String getPushToken()
Get the push token
-
onMessageReceived
public static void onMessageReceived(PushData pushData)
Notify the SDK of FCM message receipt.- Parameters:
pushData
- the push notification data
-
getReconnectTimeout
public static java.lang.Long getReconnectTimeout()
Gets reconnect timeout that was configured viaZopimChatApi.DefaultConfig.reconnectTimeout
If timeout was not configured it will return theChatSession.DEFAULT_RECONNECT_TIMEOUT
- Returns:
- reconnect timeout
-
getInitializationTimeout
public static java.lang.Long getInitializationTimeout()
Gets initialization timeout that was configured viaZopimChatApi.DefaultConfig.initializationTimeout
If timeout was not configured it will return theChatSession.DEFAULT_CHAT_INITIALIZATION_TIMEOUT
- Returns:
- initialization timeout
-
-