Package zendesk.chat

Enum Chat

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<Chat>


    public enum Chat
    extends java.lang.Enum<Chat>
    A centralized entry point into Zendesk Chat SDK.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant and Description
      INSTANCE 
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void clearCache()
      Clears and data associated with the current chat session.
      ChatProvidersConfiguration getChatProvidersConfiguration()
      Gets the current ChatProvidersConfigurationStore
      boolean hasIdentity()
      Checks whether an identity has been set up for the current chat session.
      void init(Context context, java.lang.String accountKey)
      Initializes the Chat SDK.
      void init(Context context, java.lang.String accountKey, java.lang.String appId)
      Initializes the Chat SDK with app id.
      Providers providers()
      Exposes access to all available providers within the Zendesk Chat SDK.
      void resetIdentity()
      Resets the visitor details to a clean slate allowing a new visitor to chat
      void resetIdentity(<any> completionCallback)
      Resets the visitor details to a clean slate allowing a new visitor to chat
      void setChatProvidersConfiguration(ChatProvidersConfiguration chatProvidersConfiguration)
      Sets the default configuration used when starting chats from this SDK.
      void setIdentity(JwtAuthenticator jwtAuthenticator)
      Sets up the Chat SDK to authenticate visitors using the given JwtAuthenticator
      void setIdentity(JwtAuthenticator jwtAuthenticator, <any> completionCallback)
      Sets up the Chat SDK to authenticate visitors using the given JwtAuthenticator
      static Chat valueOf(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static Chat[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • INSTANCE

        public static final Chat INSTANCE
    • Method Detail

      • values

        public static Chat[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Chat c : Chat.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Chat valueOf(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • init

        public void init(Context context,
                         java.lang.String accountKey)
        Initializes the Chat SDK.

        Call this method in your Application#onCreate().

        Parameters:
        context - context, used to access Android framework APIs.
        accountKey - your account key obtained from the web dashboard.
      • init

        public void init(Context context,
                         java.lang.String accountKey,
                         java.lang.String appId)
        Initializes the Chat SDK with app id.

        Call this method in your Application#onCreate().

        Parameters:
        context - context, used to access Android framework APIs
        accountKey - your account key obtained from the web dashboard
        appId - your id for your application
      • providers

        public Providers providers()
        Exposes access to all available providers within the Zendesk Chat SDK.

        Make sure to call Chat.init(Context, String) first.

        Returns:
        Providers or null if Chat has not been initialized.
      • setChatProvidersConfiguration

        public void setChatProvidersConfiguration(ChatProvidersConfiguration chatProvidersConfiguration)
        Sets the default configuration used when starting chats from this SDK.
        Parameters:
        chatProvidersConfiguration - the chat Configuration
      • getChatProvidersConfiguration

        public ChatProvidersConfiguration getChatProvidersConfiguration()
        Gets the current ChatProvidersConfigurationStore
        Returns:
        ChatProvidersConfigurationStore
      • setIdentity

        public void setIdentity(JwtAuthenticator jwtAuthenticator,
                                <any> completionCallback)
        Sets up the Chat SDK to authenticate visitors using the given JwtAuthenticator

        If the visitor was previously unauthenticated, any ongoing chat will be ended, and locally stored information about the visitor will be cleared.

        Calling this method unregisters the device for push notifications. To continue receiving push notifications on this device you will need to call PushNotificationsProvider.registerPushToken(String) again with your Firebase token.

        Make sure to call Chat.init(Context, String) first. If you do not, calling this method will not authenticate the user.

        Providing a JwtAuthenticator here does not guarantee that the visitor will be authenticated when they start a chat. If the Authenticator calls JwtAuthenticator.JwtCompletion#onError(), or if the token passed to zendesk.chat.JwtAuthenticator.JwtCompletion#onTokenLoaded(String)is not valid the conversation will

        This method will also clear any VisitorInfo set with Chat.setChatProvidersConfiguration(ChatProvidersConfiguration)

        This is a potentially asynchronous action due to the need to end any existing chat and unregister for chat, any callback passed to this method will be executed when it is completed. Once this method has been called, it is recommended to not attempt to interact with the SDK until the callback has been executed.

        Parameters:
        jwtAuthenticator - the JwtAuthenticator to use for authenticating visitors
        completionCallback - an optional callback which will be executed once resetting the identity has been completed and the cache has been cleared
      • setIdentity

        public void setIdentity(JwtAuthenticator jwtAuthenticator)
        Sets up the Chat SDK to authenticate visitors using the given JwtAuthenticator

        If the visitor was previously unauthenticated, any ongoing chat will be ended, and locally stored information about the visitor will be cleared.

        Calling this method unregisters the device for push notifications. To continue receiving push notifications on this device you will need to call PushNotificationsProvider.registerPushToken(String) again with your Firebase token.

        Make sure to call Chat.init(Context, String) first. If you do not, calling this method will not authenticate the user.

        Providing a JwtAuthenticator here does not guarantee that the visitor will be authenticated when they start a chat. If the Authenticator calls JwtAuthenticator.JwtCompletion#onError(), or if the token passed to zendesk.chat.JwtAuthenticator.JwtCompletion#onTokenLoaded(String)is not valid the conversation will be started as an unauthenticated user. This unauthenticated user will be cleared next time this method is called.

        This method will also clear any VisitorInfo set with Chat.setChatProvidersConfiguration(ChatProvidersConfiguration)

        This is a potentially asynchronous action due to the need to end any existing chat and unregister for chat. If you wish to continue to interact with Chat after calling this method, it is recommended that you use #setIdentity(JwtAuthenticator, CompletionCallback) so that you may be notified when it is safe to continue using the SDK.

        Parameters:
        jwtAuthenticator - the JwtAuthenticator to use for authenticating visitors
      • resetIdentity

        public void resetIdentity(<any> completionCallback)
        Resets the visitor details to a clean slate allowing a new visitor to chat

        Any ongoing chat will be ended, and locally stored information about the visitor will be cleared.

        This method will clear any Identity set with Chat.setIdentity(JwtAuthenticator). If you wish to set a new Identity, you should call that method with a new instance of JwtAuthenticator, you do not need to call this method.

        This is a potentially asynchronous action due to the need to end any existing chat and unregister for chat, any callback passed to this method will be executed when it is completed. Once this method has been called, it is recommended to not attempt to interact with the SDK until the callback has been executed.

        Parameters:
        completionCallback - an optional callback which will be executed once resetting the identity has been completed and the cache has been cleared
      • resetIdentity

        public void resetIdentity()
        Resets the visitor details to a clean slate allowing a new visitor to chat

        Any ongoing chat will be ended, and locally stored information about the visitor will be cleared.

        This method will clear any Identity set with Chat.setIdentity(JwtAuthenticator). If you wish to set a new Identity, you should call that method with a new instance of JwtAuthenticator, you do not need to call this method.

        This is a potentially asynchronous action due to the need to end any existing chat and unregister for chat. If you wish to continue to interact with Chat after calling this method, it is recommended that you use #resetIdentity(CompletionCallback) so that you may be notified when it is safe to continue using the SDK.

      • hasIdentity

        public boolean hasIdentity()
        Checks whether an identity has been set up for the current chat session.

        If a chat has not yet been started, this will return whether a value has been passed to Chat.setIdentity(JwtAuthenticator). As passing a value to this method does not guarantee that the chat session will be successfully authenticated, as there could be issues with the token returned or other failures in the authentication flow, once a chat session has been started this will return true if an authentication token has been successfully retrieved, and false if the chat has been started as unauthenticated.

        Returns:
        true if the current session is authenticated, or expected to be authenticated, false if not