Class 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( 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.

    See Also:
    Getting Started, ChatApi
    • Constructor Detail

      • ZopimChatApi

        public ZopimChatApi()
    • 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 returns 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.
        configuration builder for setting the global chat configuration
      • start

        public static ChatApi start(FragmentActivity activity)
        Starts the chat with ZopimChatApi.DefaultConfig global configuration. Chat needs to be previously initialized.
        activity - that holds the chat session
        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 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
        chat session instance
      • getDataSource

        public static DataSource getDataSource()
        Gets chat data source defined in DataSource and PathDataSource

        Data source provides subscription to data update broadcasts. It also enables to get current state of a data path.

        data source
      • setVisitorInfo

        public static void setVisitorInfo(VisitorInfo visitorInfo)
        Configures the global 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
      • 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.

        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.
        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.
        pushData - the push notification data