public class ZopimChat extends java.lang.Object implements Chat
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 Chat
used for chat communication. That chat is the bound to the lifecycle of the activity that was used to start the chat.
Chat
Modifier and Type | Class and Description |
---|---|
static class |
ZopimChat.DefaultConfig
Configuration class for global chat configuration
|
static class |
ZopimChat.SessionConfig
Configuration class for session chat configuration
|
Modifier and Type | Method and Description |
---|---|
void |
addNote(java.lang.String note) |
static void |
clearPushToken()
Clear the push token.
|
void |
disconnect() |
boolean |
emailTranscript(java.lang.String email) |
void |
endChat() |
ChatConfig |
getConfig() |
static com.zopim.android.sdk.data.DataSource |
getDataSource()
Deprecated.
use
ZopimChatApi.getDataSource() instead |
static java.lang.Long |
getInitializationTimeout()
Deprecated.
use
ZopimChatApi.getInitializationTimeout() instead |
static java.lang.Long |
getReconnectTimeout()
Deprecated.
use
ZopimChatApi.getReconnectTimeout() instead |
boolean |
hasEnded() |
static ZopimChat.DefaultConfig |
init(java.lang.String accountKey)
Initiates chat and returns
ZopimChat.DefaultConfig global configuration builder to be used for configuring the global chat settings. |
void |
resend(java.lang.String messageId) |
void |
resetTimeout() |
static Chat |
resume(android.support.v4.app.FragmentActivity activity)
Attempts to resume the existing chat if possible.
|
void |
send(java.io.File file) |
void |
send(java.lang.String message) |
void |
sendChatComment(java.lang.String comment) |
void |
sendChatRating(com.zopim.android.sdk.model.ChatLog.Rating rating) |
boolean |
sendOfflineMessage(java.lang.String name,
java.lang.String email,
java.lang.String message) |
void |
setDepartment(java.lang.String department) |
void |
setEmail(java.lang.String email) |
void |
setName(java.lang.String name) |
void |
setNote(java.lang.String note) |
void |
setPhoneNumber(java.lang.String phoneNumber) |
static void |
setPushToken(java.lang.String token)
Set the push token.
|
static void |
setVisitorInfo(com.zopim.android.sdk.model.VisitorInfo visitorInfo)
Configures the global
VisitorInfo |
static Chat |
start(android.support.v4.app.FragmentActivity activity)
Starts the chat with global configuration.
|
static void |
trackEvent(java.lang.String description)
Leaves an event trace.
|
@NonNull public static ZopimChat.DefaultConfig init(java.lang.String accountKey)
ZopimChat.DefaultConfig
global 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.@NonNull public static Chat start(android.support.v4.app.FragmentActivity activity)
activity
- that holds the chat session@NonNull public static Chat resume(android.support.v4.app.FragmentActivity activity)
Resuming a chat will be possible if the previous chat was not ended via 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 hasEnded()
.
Resumed chat might not be immediately ready to communicate, check ZopimChatApi.canCommunicate()
.
activity
- that holds the chat sessionpublic static void setPushToken(java.lang.String token)
token
- the Google/FCM device tokenpublic static void clearPushToken()
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 event@Deprecated public static com.zopim.android.sdk.data.DataSource getDataSource()
ZopimChatApi.getDataSource()
insteadDataSource
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(com.zopim.android.sdk.model.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
@Deprecated public static java.lang.Long getReconnectTimeout()
ZopimChatApi.getReconnectTimeout()
insteadZopimChatApi.DefaultConfig.reconnectTimeout
If timeout was not configured it will return the ChatSession.DEFAULT_RECONNECT_TIMEOUT
@Deprecated public static java.lang.Long getInitializationTimeout()
ZopimChatApi.getInitializationTimeout()
insteadZopimChatApi.DefaultConfig.initializationTimeout
If timeout was not configured it will return the ChatSession.DEFAULT_CHAT_INITIALIZATION_TIMEOUT
@NonNull public ChatConfig getConfig()
public boolean hasEnded()
hasEnded
in interface com.zopim.android.sdk.api.ChatApi
public void resetTimeout()
resetTimeout
in interface com.zopim.android.sdk.api.ChatApi
public void send(java.lang.String message)
send
in interface com.zopim.android.sdk.api.ChatApiCommands
public void send(@NonNull java.io.File file)
send
in interface com.zopim.android.sdk.api.ChatApiCommands
public void resend(java.lang.String messageId)
resend
in interface com.zopim.android.sdk.api.ChatApiCommands
public boolean sendOfflineMessage(java.lang.String name, java.lang.String email, java.lang.String message)
sendOfflineMessage
in interface com.zopim.android.sdk.api.ChatApiCommands
public void sendChatRating(@NonNull com.zopim.android.sdk.model.ChatLog.Rating rating)
sendChatRating
in interface com.zopim.android.sdk.api.ChatApiCommands
public void sendChatComment(@NonNull java.lang.String comment)
sendChatComment
in interface com.zopim.android.sdk.api.ChatApiCommands
public boolean emailTranscript(java.lang.String email)
emailTranscript
in interface com.zopim.android.sdk.api.ChatApiCommands
public void endChat()
endChat
in interface com.zopim.android.sdk.api.ChatApiCommands
public void disconnect()
disconnect
in interface com.zopim.android.sdk.api.ChatApiCommands
public void setDepartment(java.lang.String department)
setDepartment
in interface com.zopim.android.sdk.api.ChatApiCommands
public void setPhoneNumber(java.lang.String phoneNumber)
setPhoneNumber
in interface com.zopim.android.sdk.api.ChatApiCommands
public void setName(java.lang.String name)
setName
in interface com.zopim.android.sdk.api.ChatApiCommands
public void setEmail(java.lang.String email)
setEmail
in interface com.zopim.android.sdk.api.ChatApiCommands
public void setNote(java.lang.String note)
setNote
in interface com.zopim.android.sdk.api.ChatApiCommands
public void addNote(java.lang.String note)
addNote
in interface com.zopim.android.sdk.api.ChatApiCommands