BoldChatSession
com.boldchat.sdk
Class BoldChatSession
- java.lang.Object
-
- com.boldchat.sdk.BoldChatSession
-
public class BoldChatSession extends java.lang.Object
Android UI component helper class for interacting with the Bold Chat API. To get started using this class make a new instance ofBoldChatSession.Builder
with the required minimum arguments of accountI ID (assigned by BoldChat), and chat API access key (also assigned by bold chat). With this instance of Builder you can set up the various chat UI elements such as the message input area, a message history web view, and a send button. The chat session instance will be wired up to be able to handle the appropriate events from these views. After done setting up the Builder instance callBoldChatSession.Builder.build()
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static interface
BoldChatSession.BoldChatSessionListener
Callback BoldChatSessionListener to receive events on major state changes of the chat session.static class
BoldChatSession.Builder
The builder class used to set up all the UI components for use by theBoldChatSession
object.static interface
BoldChatSession.ChatFormListener
Callback that will be called before a form is shown.
-
Method Summary
Methods Modifier and Type Method and Description void
addMenuItems(android.view.MenuInflater inflater, android.view.Menu menu)
Adds menu options related to the chat session.void
closeChat()
Close the chat, this also triggers a call toBoldChatSession.BoldChatSessionListener.chatSessionClosed()
.void
endChat(boolean manuallyEnded)
Ends the chat, and shows post-chat survey if enabled, otherwise callsBoldChatSession.BoldChatSessionListener.chatSessionClosed()
.void
getChatAvailability(ChatAvailabilityListener availabilityListener)
Gets the current status of chat availability.boolean
isChatActive()
Determines if theBoldChatSession
object appears to have an active chat.boolean
menuItemSelected(android.view.MenuItem item)
When a menu item is selected, this method is used to notify the BoldChat session and give it an opportunity to process the selected item.void
removeListener()
Removes the listener if one is set, after calling this method no UI updates will occur.void
setChatFormListener(BoldChatSession.ChatFormListener chatFormListener)
Sets the listener that will be called before a form is shown.void
setListener(BoldChatSession.BoldChatSessionListener boldChatSessionListener)
Sets a listener that will be notified on status changes of the bc_chat session.void
start()
Starts the chat session, this should be called at the appropriate time after callingBoldChatSession.Builder.build()
to begin the chat.
-
-
-
Method Detail
-
addMenuItems
public void addMenuItems(android.view.MenuInflater inflater, android.view.Menu menu)
Adds menu options related to the chat session.- Parameters:
inflater
- The menu inflater for the action bar.menu
- The current menu for the action bar.
-
menuItemSelected
public boolean menuItemSelected(android.view.MenuItem item)
When a menu item is selected, this method is used to notify the BoldChat session and give it an opportunity to process the selected item. Ideally this method would be called fromActivity.onMenuItemSelected(int, android.view.MenuItem)
, orandroid.support.v7.app.ActionBarActivity#onOptionsItemSelected(android.view.MenuItem)
.- Parameters:
item
- The menu item that was selected.- Returns:
- true if the menu item belonged to the BoldChat session and was processed, false for all other menu items.
-
start
public void start()
Starts the chat session, this should be called at the appropriate time after callingBoldChatSession.Builder.build()
to begin the chat. For example this could be called fromActivity.onCreate(android.os.Bundle)
orActivity.onResume()
. This should only be called if you want to create a new chat, or if there is a chat already active you want to resume.
-
endChat
public void endChat(boolean manuallyEnded)
Ends the chat, and shows post-chat survey if enabled, otherwise callsBoldChatSession.BoldChatSessionListener.chatSessionClosed()
.
-
closeChat
public void closeChat()
Close the chat, this also triggers a call toBoldChatSession.BoldChatSessionListener.chatSessionClosed()
.
-
getChatAvailability
public void getChatAvailability(ChatAvailabilityListener availabilityListener)
Gets the current status of chat availability. Results will be cached for up to 5 minutes.- Parameters:
availabilityListener
- The listener to receive the current chat availability.
-
isChatActive
public boolean isChatActive()
Determines if theBoldChatSession
object appears to have an active chat.- Returns:
- true if there is an active chat, false otherwise.
-
setChatFormListener
public void setChatFormListener(BoldChatSession.ChatFormListener chatFormListener)
Sets the listener that will be called before a form is shown. This will give the listener an opportunity to pre-fill field values, hide fields, or prevent the form from showing entirely.- Parameters:
chatFormListener
- The listener to receive form events.
-
setListener
public void setListener(BoldChatSession.BoldChatSessionListener boldChatSessionListener)
Sets a listener that will be notified on status changes of the bc_chat session.- Parameters:
boldChatSessionListener
- The listener to receive the status events.
-
removeListener
public void removeListener()
Removes the listener if one is set, after calling this method no UI updates will occur. This should be called from onPause, onStop, or onDestroy. The listener can be re-registered usingsetListener(com.boldchat.sdk.BoldChatSession.BoldChatSessionListener)
.
-
-