Class UnbluClientConfiguration.Builder
- java.lang.Object
-
- com.unblu.sdk.core.configuration.UnbluClientConfiguration.Builder
-
- Enclosing class:
- UnbluClientConfiguration
public static final class UnbluClientConfiguration.Builder extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Builder(UnbluClientConfiguration unbluClientConfiguration)
Constructs an API configuration.Builder(java.lang.String unbluBaseUrl, java.lang.String apiKey, UnbluPreferencesStorage preferencesStorage, UnbluDownloadHandler downloadHandler, UnbluExternalLinkHandler externalLinkHandler)
Constructs an API configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UnbluClientConfiguration
build()
Generates the immutable UnbluConfiguration instance based on the state of the builder at the time when it's called.UnbluClientConfiguration.Builder
registerModule(UnbluModule module)
Registers a module that you want to use in your app, for example, for calls or mobile co-browsing.UnbluClientConfiguration.Builder
setAccessToken(java.lang.String accessToken)
Defines the access token for visitor single sign-on (SSO).UnbluClientConfiguration.Builder
setApiKey(java.lang.String apiKey)
Sets the Unblu API key within this Builder instance.UnbluClientConfiguration.Builder
setAudioUploadsEnabled(boolean audioUploadsEnabled)
Enables or disables direct audio uploads from the app.UnbluClientConfiguration.Builder
setCameraUploadsEnabled(boolean cameraUploadsEnabled)
Enables or disables direct uploads from the camera app.UnbluClientConfiguration.Builder
setCustomCookies(java.util.Set<UnbluCookie> customCookies)
Configures a Set of cookies which will be set on the configured base URL.UnbluClientConfiguration.Builder
setDownloadHandler(UnbluDownloadHandler downloadHandler)
Defines the handler for downloads.UnbluClientConfiguration.Builder
setEntryPath(java.lang.String entryPath)
Sets the Unblu entry path to connect to the Unblu server.UnbluClientConfiguration.Builder
setInternalUrlPatternWhitelist(java.util.List<java.util.regex.Pattern> internalUrlPatternWhitelist)
Sets the list of URL patterns that may be accessed by the WebView.UnbluClientConfiguration.Builder
setLanguage(java.lang.String language)
Sets the language to send to the Unblu server.UnbluClientConfiguration.Builder
setNamedArea(java.lang.String namedArea)
Sets the named area for which the configuration is loaded when the API is initializing.UnbluClientConfiguration.Builder
setNotificationInterceptor(NotificationInterceptor notificationInterceptor)
Specifies a notification interceptor to transform notification before they're displayed.UnbluClientConfiguration.Builder
setNotificationsEnabled(boolean notificationsEnabled)
Enables or disables notifications via Unblu.UnbluClientConfiguration.Builder
setOAuthToken(java.lang.String token)
Sets the initial OAuth 2.0 token received from an identity provider.UnbluClientConfiguration.Builder
setPhotoUploadsEnabled(boolean photoUploadsEnabled)
Enables or disables direct photo uploads from the camera app.UnbluClientConfiguration.Builder
setPreferencesStorage(UnbluPreferencesStorage preferencesStorage)
Defines the storage implementation to save and retrieve preferences of the SDK.
A default implementation can be used viaUnbluPreferencesStorage.createSharedPreferencesStorage(Context)
.UnbluClientConfiguration.Builder
setUnbluBaseUrl(java.lang.String unbluBaseUrl)
Sets the base URL of the Unblu server (http(s)://domain:port)UnbluClientConfiguration.Builder
setUnbluClientCertRequestData(UnbluClientCertRequestData unbluClientCertRequestData)
Defines theUnbluClientCertRequestData
data required for a client certificate request in the Unblu SDK.UnbluClientConfiguration.Builder
setUnbluExternalLinkHandler(UnbluExternalLinkHandler externalLinkPatternWhitelist)
Sets the list of link patterns that may be opened in the system browser.UnbluClientConfiguration.Builder
setVideoUploadsEnabled(boolean videoUploadsEnabled)
Enables or disables direct video uploads from the camera app.UnbluClientConfiguration.Builder
unregisterModule(UnbluModule module)
Unregisters a module which should no longer be used, for example, for calls or mobile co-browsing.
-
-
-
Constructor Detail
-
Builder
public Builder(@NonNull UnbluClientConfiguration unbluClientConfiguration)
Constructs an API configuration. The configuration is an immutable instance ofUnbluClientConfiguration
.- Parameters:
unbluClientConfiguration
- The current UnbluConfiguration object
-
Builder
public Builder(@NonNull java.lang.String unbluBaseUrl, @NonNull java.lang.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 Detail
-
setUnbluBaseUrl
public UnbluClientConfiguration.Builder setUnbluBaseUrl(@NonNull java.lang.String unbluBaseUrl)
Sets the base URL of the Unblu server (http(s)://domain:port)
-
setApiKey
public UnbluClientConfiguration.Builder setApiKey(@NonNull java.lang.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 java.util.List<java.util.regex.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
public UnbluClientConfiguration.Builder setEntryPath(@Nullable java.lang.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 java.lang.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 java.util.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 java.lang.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 java.lang.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 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
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 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
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 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
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 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
public UnbluClientConfiguration.Builder setAccessToken(@NonNull java.lang.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 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
public UnbluClientConfiguration build()
Generates the immutable UnbluConfiguration instance based on the state of the builder at the time when it's called.
-
-