public class ChatService extends Service
Controls chat session communication via WebBinder
instance.
It will configure chat based on the global configuration provided at initialization time using ZopimChatApi.DefaultConfig
or
session configuration provided at start time using ZopimChatApi.SessionConfig
.
ZopimChatApi
Modifier and Type | Class and Description |
---|---|
class |
ChatService.LocalBinder
Class used for the client Binder.
|
START_CONTINUATION_MASK, START_FLAG_REDELIVERY, START_FLAG_RETRY, START_NOT_STICKY, START_REDELIVER_INTENT, START_STICKY, START_STICKY_COMPATIBILITY
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APP_OPS_SERVICE, APPWIDGET_SERVICE, AUDIO_SERVICE, BATTERY_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAMERA_SERVICE, CAPTIONING_SERVICE, CARRIER_CONFIG_SERVICE, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, FINGERPRINT_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, JOB_SCHEDULER_SERVICE, KEYGUARD_SERVICE, LAUNCHER_APPS_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_PROJECTION_SERVICE, MEDIA_ROUTER_SERVICE, MEDIA_SESSION_SERVICE, MIDI_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NETWORK_STATS_SERVICE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, PRINT_SERVICE, RESTRICTIONS_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, STORAGE_SERVICE, TELECOM_SERVICE, TELEPHONY_SERVICE, TELEPHONY_SUBSCRIPTION_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, TV_INPUT_SERVICE, UI_MODE_SERVICE, USAGE_STATS_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
Constructor and Description |
---|
ChatService() |
Modifier and Type | Method and Description |
---|---|
boolean |
emailTranscript(String email)
Emails the current chat transcript
|
void |
endChat()
Ends the current chat.
|
protected void |
finalize() |
ChatApiConfig |
getConfig()
Gets chat config for the current chat session as configured via
ZopimChatApi |
boolean |
hasEnded()
Tells if this chat session has ended and can not be continued.
|
IBinder |
onBind(Intent intent) |
void |
onCreate()
The system calls this method when the service is first created, to perform one-time setup procedures (before it calls either onStartCommand() or onBind()).
|
void |
onDestroy() |
int |
onStartCommand(Intent intent,
int flags,
int startId)
Starting a sticky service that has to be stopped explicitly.
|
void |
resend(String messageId)
Re-sends the visitor message.
|
void |
resetTimeout()
Resets chat timeout.
|
void |
send(File file)
Sends the file to the current chat log.
|
void |
send(String message)
Sends the visitor message.
|
void |
sendChatComment(String comment)
Sets a comment to the current chat session.
|
void |
sendChatRating(ChatLog.Rating rating)
Sets rating for the current chat session.
|
void |
sendEvents(Event... events)
Sends events to the dashboard
|
boolean |
sendOfflineMessage(String name,
String email,
String message)
Sends email to agents defined in the dashboard for this account.
|
void |
setDepartment(String department)
Sets a department to the current chat session.
|
void |
setEmail(String email)
Sets the email for the user in the current chat session.
|
void |
setName(String name)
Sets the name for the user in the current chat session.
|
void |
setPhoneNumber(String phoneNumber)
Sets phone number information for the user that is in the current chat session.
|
dump, getApplication, onConfigurationChanged, onLowMemory, onRebind, onStart, onTaskRemoved, onTrimMemory, onUnbind, startForeground, stopForeground, stopSelf, stopSelf, stopSelfResult
attachBaseContext, bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkSelfPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createDisplayContext, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getCodeCacheDir, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getFileStreamPath, getMainLooper, getNoBackupFilesDir, getObbDir, getObbDirs, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getSystemService, getSystemServiceName, getTheme, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setTheme, setWallpaper, setWallpaper, startActivities, startActivities, startActivity, startActivity, startInstrumentation, startIntentSender, startIntentSender, startService, stopService, unbindService, unregisterReceiver
getColor, getColorStateList, getDrawable, getString, getString, getSystemService, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks
public void onCreate()
public int onStartCommand(Intent intent, int flags, int startId)
ZopimChatApi
will be set.onStartCommand
in class Service
protected void finalize() throws Throwable
public ChatApiConfig getConfig()
ChatApi
ZopimChatApi
It will reflect ZopimChatApi.DefaultConfig
configuration values unless overridden via ZopimChatApi.SessionConfig
at chat start.
public void setDepartment(String department)
ChatApiCommands
Configuring a department in the chat will deliver the chat to the right group of agents supporting that department's inquiries. This information will be visible in the agent dashboard.
Provided department should be one of the departments available in this account.
The list of available departments will be available in LivechatDepartmentsPath
after initialization is complete onChatInitialized()
.
Setting a non defined department will have no effect.
department
- visitor is chatting withpublic void setPhoneNumber(String phoneNumber)
Phone number will be stored in local storage for later retrieval.
You can disable visitor info storage via PrefsStorage.disable()
. Obtain storage instance through Storage.visitorInfo()
phoneNumber
- of the visitorpublic void setName(String name)
Name will be stored in local storage for later retrieval.
You can disable visitor info storage via PrefsStorage.disable()
. Obtain storage instance through Storage.visitorInfo()
name
- of the visitorpublic void setEmail(String email)
Email will be stored in local storage for later retrieval.
You can disable visitor info storage via PrefsStorage.disable()
. Obtain storage instance through Storage.visitorInfo()
email
- of the visitorpublic void send(String message)
ChatApiCommands
This message will appear in the agent dashboard in an active chat queue.
message
- to be sentpublic void send(File file)
ChatApiCommands
File must pass validation check and upload requirements defined in Zopim attachments page
A successful file upload will be visible in the agent dashboard.
file
- to sendChatLogObserver
,
Agent Dashboardpublic void resend(String messageId)
ChatApiCommands
This message will appear in the agent dashboard.
messageId
- id of the message to resendpublic void sendChatRating(@NonNull ChatLog.Rating rating)
ChatApiCommands
This will appear as a response to the chat rating questionnaire sent by an agent to the visitor.
rating
- to setpublic void sendChatComment(@NonNull String comment)
ChatApiCommands
comment
- to setpublic void sendEvents(Event... events)
This will result in a dashboard visitor path event
events
- descriptionpublic void endChat()
After the chat has ended the service will attempt to stop itself but will remain running until it's unbound from the host activity. All cached attachments will be cleared.
public boolean hasEnded()
ChatApi
public boolean emailTranscript(String email)
ChatApiCommands
It will send an email to the provided address with the current chat log
email
- address to send the transcript topublic boolean sendOfflineMessage(String name, String email, String message)
ChatApiCommands
Email must be provided in order for the agent to be able to respond.
name
- of the visitoremail
- of the visitormessage
- inquirypublic void resetTimeout()
ChatApi
ZopimChatApi.DefaultConfig.sessionTimeout(long)
.