public abstract class ZopimChatApi extends java.lang.Object implements ChatApi, ChatSession
Firstly, to initialize the chat call 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
start(android.support.v4.app.FragmentActivity)
.
Starting a chat will provide an instance of ChatApi
used for chat communication. That chat is the bound to
the lifecycle of the activity that was used to start the chat.
ChatApi
Modifier and Type | Class and Description |
---|---|
static class |
ZopimChatApi.DefaultConfig<T extends ZopimChatApi.DefaultConfig>
Configuration class for global chat configuration
|
static class |
ZopimChatApi.SessionConfig<T extends ZopimChatApi.SessionConfig>
Configuration class for session chat configuration
|
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 and Description |
---|
ZopimChatApi() |
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 in
DataSource and PathDataSource |
static java.lang.Long |
getInitializationTimeout()
Gets initialization timeout that was configured via
ZopimChatApi.DefaultConfig.initializationTimeout
If timeout was not configured it will return the ChatSession.DEFAULT_CHAT_INITIALIZATION_TIMEOUT |
static java.lang.String |
getPushToken()
Get the push token
|
static java.lang.Long |
getReconnectTimeout()
Gets reconnect timeout that was configured via
ZopimChatApi.DefaultConfig.reconnectTimeout
If timeout was not configured it will return the ChatSession.DEFAULT_RECONNECT_TIMEOUT |
static ZopimChatApi.DefaultConfig |
init(java.lang.String accountKey)
Initiates chat and returns
ZopimChatApi.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 ChatApi |
resume(android.support.v4.app.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 global
VisitorInfo |
static ChatApi |
start(android.support.v4.app.FragmentActivity activity)
Starts the chat with
ZopimChatApi.DefaultConfig global configuration. |
static void |
trackEvent(java.lang.String description)
Leaves an event trace.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConfig, hasEnded, resetTimeout
addNote, disconnect, emailTranscript, endChat, resend, send, send, sendChatComment, sendChatRating, sendOfflineMessage, setDepartment, setEmail, setName, setNote, setPhoneNumber
public static ZopimChatApi.DefaultConfig init(java.lang.String accountKey)
ZopimChatApi.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.accountKey
- Your account key obtained from the Zopim widget config page. Will configure chat to use your
Zopim instance.public static ChatApi start(android.support.v4.app.FragmentActivity activity)
ZopimChatApi.DefaultConfig
global configuration. Chat
needs to be previously initialized.activity
- that holds the chat sessionpublic static ChatApi resume(android.support.v4.app.FragmentActivity activity)
Resuming a chat will be possible if the previous chat was not ended via ChatApiCommands.endChat()
or
expired.
Chat timeout time, defined here ChatSession.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 ended
ChatApi.hasEnded()
.
Resumed chat might not be immediately ready to communicate.
activity
- that holds the chat session@NonNull public static DataSource getDataSource()
DataSource
and PathDataSource
Data source provides subscription to data update broadcasts. It also enables to get current state of a data path.
public static void setVisitorInfo(VisitorInfo visitorInfo)
VisitorInfo
Visitor info can be set at any point, but the changes will take effect at next chat session start
visitorInfo
- visitor data from VisitorInfo
public static void trackEvent(java.lang.String description)
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.
description
- of the eventpublic static void setPushToken(java.lang.String token)
token
- the token received from FCMpublic static void clearPushToken()
@Nullable public static java.lang.String getPushToken()
public static void onMessageReceived(@NonNull PushData pushData)
pushData
- the push notification data@NonNull public static java.lang.Long getReconnectTimeout()
ZopimChatApi.DefaultConfig.reconnectTimeout
If timeout was not configured it will return the ChatSession.DEFAULT_RECONNECT_TIMEOUT
@NonNull public static java.lang.Long getInitializationTimeout()
ZopimChatApi.DefaultConfig.initializationTimeout
If timeout was not configured it will return the ChatSession.DEFAULT_CHAT_INITIALIZATION_TIMEOUT