Class UnbluClientConfiguration.Builder

java.lang.Object
com.unblu.sdk.core.configuration.UnbluClientConfiguration.Builder
Enclosing class:
UnbluClientConfiguration

public static final class UnbluClientConfiguration.Builder extends Object
  • Constructor Details

    • Builder

      public Builder(@NonNull UnbluClientConfiguration unbluClientConfiguration)
      Constructs an API configuration. The configuration is an immutable instance of UnbluClientConfiguration.
      Parameters:
      unbluClientConfiguration - The current UnbluConfiguration object
    • Builder

      public Builder(@NonNull String unbluBaseUrl, @NonNull String apiKey, @NonNull UnbluPreferencesStorage preferencesStorage, @NonNull UnbluDownloadHandler downloadHandler, UnbluExternalLinkHandler externalLinkHandler)
      Constructs an API configuration. The configuration is an immutable instance of UnbluClientConfiguration.

      The default implementations can be used for the UnbluPreferencesStorage, the UnbluDownloadHandler, and the UnbluExternalLinkHandler.

      Parameters:
      unbluBaseUrl - The URL to the Unblu server. (base URL: http(s)://domain:port)
      apiKey - The Unblu API key you want to use for your mobile application
      preferencesStorage - The storage implementation to save and retrieve preferences of the SDK
      downloadHandler - The download handler implementation to handle file downloads
      externalLinkHandler - The link handler used by Unblu to determine what action to take when an external link is tapped in a conversation.
  • Method Details

    • setUnbluBaseUrl

      public UnbluClientConfiguration.Builder setUnbluBaseUrl(@NonNull String unbluBaseUrl)
      Sets the base URL of the Unblu server (http(s)://domain:port)
    • setApiKey

      public UnbluClientConfiguration.Builder setApiKey(@NonNull String apiKey)
      Sets the Unblu API key within this Builder instance.
      Parameters:
      apiKey - The Unblu API key you want to use for your mobile application
      Returns:
      The configuration to chain multiple calls
    • setInternalUrlPatternWhitelist

      public UnbluClientConfiguration.Builder setInternalUrlPatternWhitelist(@NonNull List<Pattern> internalUrlPatternWhitelist)
      Sets the list of URL patterns that may be accessed by the WebView.

      The pattern whitelist restricts access to:

      • URLs loaded in the WebView
      • all assets (CSS, JS, images and so on)
      • AJAX requests

      The baseURL of the configuration is automatically added to the list.

      The list is mainly required if you use redirects from the initial base URL to a different domain, or if you load resources such web fonts from other locations, for example Google Fonts.

      Parameters:
      internalUrlPatternWhitelist - A list of URL patterns which may be accessed by the WebView
      Returns:
      The configuration to chain multiple calls
    • setUnbluExternalLinkHandler

      public UnbluClientConfiguration.Builder setUnbluExternalLinkHandler(@NonNull UnbluExternalLinkHandler externalLinkPatternWhitelist)
      Sets the list of link patterns that may be opened in the system browser. This determines what action to take when a user taps on an external link in a chat.

      The following patterns are added by default:

      • ^\Qhttps://\E.*
      • ^\Qmailto://\E.*
      • ^\Qtel:\E.*
      Calling this function overrides the default patterns.

      If a link doesn't match any of the patterns above, tapping it has no effect.

      Parameters:
      externalLinkPatternWhitelist - A list of URL patterns which may be opened in the system browser
      Returns:
      The configuration to chain multiple calls
    • setEntryPath

      public UnbluClientConfiguration.Builder setEntryPath(@Nullable String entryPath)
      Sets the Unblu entry path to connect to the Unblu server. The default is null, which will use the entry paths "/unblu" and "/app" for the visitor and agent clients, respectively.
      Remember to include a leading slash!
      Parameters:
      entryPath - The entry path used to connect to the Unblu server The default values are "/unblu" (for visitor clients) and "/app" (for agent clients).
      Returns:
      The configuration to chain multiple calls
    • setOAuthToken

      public UnbluClientConfiguration.Builder setOAuthToken(@Nullable String token)
      Sets the initial OAuth 2.0 token received from an identity provider. The token is passed to the service worker and used in the authorization header.
      For more information, refer to RFC6750, The OAuth 2.0 Authorization Framework: Bearer Token Usage.
      Parameters:
      token - The token value
      Returns:
      The configuration to chain multiple calls
    • setCustomCookies

      public UnbluClientConfiguration.Builder setCustomCookies(@NonNull Set<UnbluCookie> customCookies)
      Configures a Set of cookies which will be set on the configured base URL. The SDK only stores a copy of the given Set.
      Parameters:
      customCookies - The cookies to set on the configured base URL
      Returns:
      The configuration to chain multiple calls
    • setLanguage

      public UnbluClientConfiguration.Builder setLanguage(@Nullable String language)
      Sets the language to send to the Unblu server. This defines the language used within the UI. If no language is defined explicitly, the system language of the device is used.
      Parameters:
      language - The language to send to the Unblu server
      Returns:
      The configuration to chain multiple calls
    • setNamedArea

      public UnbluClientConfiguration.Builder setNamedArea(@Nullable String namedArea)
      Sets the named area for which the configuration is loaded when the API is initializing. When sessions are started and subsequently put into the queue on the Agent Desk, they can be filtered by the defined named area. The named area must be configured in the Unblu Account Configuration interface.

      You can change the named area after initializing the API by calling UnbluVisitorClient.setNamedArea(String).

      Parameters:
      namedArea - The meta-tag ID of the named area, as configured in the Unblu Account Configuration interface
      Returns:
      The configuration to chain multiple calls
    • setNotificationsEnabled

      public UnbluClientConfiguration.Builder setNotificationsEnabled(boolean notificationsEnabled)
      Enables or disables notifications via Unblu. By default notifications are enabled.
      Parameters:
      notificationsEnabled - If true, notifications are enabled, otherwise they're disabled.
      Returns:
      The configuration to chain multiple calls
    • setCameraUploadsEnabled

      public UnbluClientConfiguration.Builder setCameraUploadsEnabled(boolean cameraUploadsEnabled)
      Enables or disables direct uploads from the camera app. This has the same effect as enabling both photo uploads and video uploads. By default, direct uploads are enabled.
      The images captured via the camera app are stored in a temporary file inside the external storage folder, where they may be accessed by other apps with the permission Manifest.permission.READ_EXTERNAL_STORAGE.

      This will set both setVideoUploadsEnabled(boolean) and setPhotoUploadsEnabled(boolean) to the specified value.

      Parameters:
      cameraUploadsEnabled - If set to true, uploads directly via the camera app are enabled.
      Returns:
      The configuration to chain multiple calls
    • setVideoUploadsEnabled

      public UnbluClientConfiguration.Builder setVideoUploadsEnabled(boolean videoUploadsEnabled)
      Enables or disables direct video uploads from the camera app. By default, they're enabled.
      The videos captured are stored in a temporary file inside the external storage folder, where they may be accessed by other apps with the permission Manifest.permission.READ_EXTERNAL_STORAGE.
      Parameters:
      videoUploadsEnabled - If set to true, video uploads directly via the camera app are enabled.
      Returns:
      The configuration to chain multiple calls
    • setAudioUploadsEnabled

      public UnbluClientConfiguration.Builder setAudioUploadsEnabled(boolean audioUploadsEnabled)
      Enables or disables direct audio uploads from the app. By default, they're enabled.

      Note: For audio uploads to work, the device where the app is installed must have an app that handles the action MediaStore.Audio.Media.RECORD_SOUND_ACTION to perform and deliver the recording.

      Parameters:
      audioUploadsEnabled - If set to true, direct audio uploads are enabled.
      Returns:
      The configuration to chain multiple calls
    • setPhotoUploadsEnabled

      public UnbluClientConfiguration.Builder setPhotoUploadsEnabled(boolean photoUploadsEnabled)
      Enables or disables direct photo uploads from the camera app. By default, they're enabled.
      The images captured via the camera app are stored in a temporary file in the external storage folder, where they may be accessed by other apps with the permission Manifest.permission.READ_EXTERNAL_STORAGE.
      Parameters:
      photoUploadsEnabled - If set to true, photo uploads directly via the camera app are enabled.
      Returns:
      The configuration to chain multiple calls
    • setPreferencesStorage

      public UnbluClientConfiguration.Builder setPreferencesStorage(@NonNull UnbluPreferencesStorage preferencesStorage)
      Defines the storage implementation to save and retrieve preferences of the SDK.
      A default implementation can be used via UnbluPreferencesStorage.createSharedPreferencesStorage(Context). This stores the preferences of the SDK inside the SharedPreferences of the app with Context.MODE_PRIVATE.
      Parameters:
      preferencesStorage - The storage where the SDK saves its preferences.
      Returns:
      The configuration to chain multiple calls
    • registerModule

      public UnbluClientConfiguration.Builder registerModule(@NonNull UnbluModule module)
      Registers a module that you want to use in your app, for example, for calls or mobile co-browsing. You must register the modules of features you want to use or they won't work.
      Parameters:
      module - The module to register
      Returns:
      The configuration to chain multiple calls
    • unregisterModule

      public UnbluClientConfiguration.Builder unregisterModule(@NonNull UnbluModule module)
      Unregisters a module which should no longer be used, for example, for calls or mobile co-browsing.
      Parameters:
      module - The module to unregister
      Returns:
      The configuration to chain multiple calls
    • setNotificationInterceptor

      public UnbluClientConfiguration.Builder setNotificationInterceptor(NotificationInterceptor notificationInterceptor)
      Specifies a notification interceptor to transform notification before they're displayed.
      Parameters:
      notificationInterceptor - An implementation of NotificationInterceptor that should be used to transform notifications
      Returns:
      The configuration to chain multiple calls
    • setDownloadHandler

      public UnbluClientConfiguration.Builder setDownloadHandler(@NonNull UnbluDownloadHandler downloadHandler)
      Defines the handler for downloads. The handler must handle the entire download process.
      The SDK has a default implementation that can be used via UnbluDownloadHandler.createExternalStorageDownloadHandler(Application). It stores files in the public downloads directory.
      Parameters:
      downloadHandler - The listener that handles all file downloads
      Returns:
      The configuration to chain multiple calls
    • setAccessToken

      public UnbluClientConfiguration.Builder setAccessToken(@NonNull String accessToken)
      Defines the access token for visitor single sign-on (SSO). It's ignored for agent sessions.
      Parameters:
      accessToken - The string value for the access token. This should be a JSON Web Token.
      Returns:
      The configuration to chain multiple calls
    • setUnbluClientCertRequestData

      public UnbluClientConfiguration.Builder setUnbluClientCertRequestData(@Nullable UnbluClientCertRequestData unbluClientCertRequestData)
      Defines the UnbluClientCertRequestData data required for a client certificate request in the Unblu SDK.
      Parameters:
      unbluClientCertRequestData - Instance of the data required for a client certificate request in the Unblu SDK
      Returns:
      The configuration; used to chain multiple calls
    • build

      public UnbluClientConfiguration build()
      Generates the immutable UnbluConfiguration instance based on the state of the builder at the time when it's called.