Class UnbluClientConfiguration.Builder
- Enclosing class:
- UnbluClientConfiguration
-
Constructor Summary
ConstructorDescriptionBuilder
(UnbluClientConfiguration unbluClientConfiguration) Constructs an API configuration.Builder
(String unbluBaseUrl, String apiKey, UnbluPreferencesStorage preferencesStorage, UnbluDownloadHandler downloadHandler, UnbluExternalLinkHandler externalLinkHandler) Constructs an API configuration. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Generates the immutable UnbluConfiguration instance based on the state of the builder at the time when it's called.registerModule
(UnbluModule module) Registers a module that you want to use in your app, for example, for calls or mobile co-browsing.setAccessToken
(String accessToken) Defines the access token for visitor single sign-on (SSO).Sets the Unblu API key within this Builder instance.setAudioUploadsEnabled
(boolean audioUploadsEnabled) Enables or disables direct audio uploads from the app.setCameraUploadsEnabled
(boolean cameraUploadsEnabled) Enables or disables direct uploads from the camera app.setCustomCookies
(Set<UnbluCookie> customCookies) Configures a Set of cookies which will be set on the configured base URL.setDownloadHandler
(UnbluDownloadHandler downloadHandler) Defines the handler for downloads.setEntryPath
(String entryPath) Sets the Unblu entry path to connect to the Unblu server.setInternalUrlPatternWhitelist
(List<Pattern> internalUrlPatternWhitelist) Sets the list of URL patterns that may be accessed by the WebView.setLanguage
(String language) Sets the language to send to the Unblu server.setNamedArea
(String namedArea) Sets the named area for which the configuration is loaded when the API is initializing.setNotificationInterceptor
(NotificationInterceptor notificationInterceptor) Specifies a notification interceptor to transform notification before they're displayed.setNotificationsEnabled
(boolean notificationsEnabled) Enables or disables notifications via Unblu.setOAuthToken
(String token) Sets the initial OAuth 2.0 token received from an identity provider.setPhotoUploadsEnabled
(boolean photoUploadsEnabled) Enables or disables direct photo uploads from the camera app.setPreferencesStorage
(UnbluPreferencesStorage preferencesStorage) Defines the storage implementation to save and retrieve preferences of the SDK.
A default implementation can be used viaUnbluPreferencesStorage.createSharedPreferencesStorage(Context)
.setUnbluBaseUrl
(String unbluBaseUrl) Sets the base URL of the Unblu server (http(s)://domain:port)setUnbluClientCertRequestData
(UnbluClientCertRequestData unbluClientCertRequestData) Defines theUnbluClientCertRequestData
data required for a client certificate request in the Unblu SDK.setUnbluExternalLinkHandler
(UnbluExternalLinkHandler externalLinkPatternWhitelist) Sets the list of link patterns that may be opened in the system browser.setVideoUploadsEnabled
(boolean videoUploadsEnabled) Enables or disables direct video uploads from the camera app.unregisterModule
(UnbluModule module) Unregisters a module which should no longer be used, for example, for calls or mobile co-browsing.
-
Constructor Details
-
Builder
Constructs an API configuration. The configuration is an immutable instance ofUnbluClientConfiguration
.- 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 ofUnbluClientConfiguration
.The default implementations can be used for the
UnbluPreferencesStorage
, theUnbluDownloadHandler
, and theUnbluExternalLinkHandler
.- 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 applicationpreferencesStorage
- The storage implementation to save and retrieve preferences of the SDKdownloadHandler
- The download handler implementation to handle file downloadsexternalLinkHandler
- The link handler used by Unblu to determine what action to take when an external link is tapped in a conversation.
-
-
Method Details
-
setUnbluBaseUrl
Sets the base URL of the Unblu server (http(s)://domain:port) -
setApiKey
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.*
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
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
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
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
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
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
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
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 permissionManifest.permission.READ_EXTERNAL_STORAGE
.This will set both
setVideoUploadsEnabled(boolean)
andsetPhotoUploadsEnabled(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
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 permissionManifest.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
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
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 permissionManifest.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 viaUnbluPreferencesStorage.createSharedPreferencesStorage(Context)
. This stores the preferences of the SDK inside the SharedPreferences of the app withContext.MODE_PRIVATE
.- Parameters:
preferencesStorage
- The storage where the SDK saves its preferences.- Returns:
- The configuration to chain multiple calls
-
registerModule
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
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 ofNotificationInterceptor
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 viaUnbluDownloadHandler.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
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 theUnbluClientCertRequestData
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
Generates the immutable UnbluConfiguration instance based on the state of the builder at the time when it's called.
-