Interface UnbluClient
- All Known Subinterfaces:
UnbluAgentClient,UnbluVisitorClient
UnbluAgentClient and UnbluVisitorClient.
Minumum requirements:
Android API version 24
Unblu Collaboration Server 6.33.x or newer
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddPersonLabel(String name, IPersonLabelActionCallback onResult) Adds a label to the current person.voiddeinitClient(SuccessVoidCallback success, DeinitializeExceptionCallback failure) Deinitializes the UnbluClient.voidgetConversations(SuccessCallback<List<ConversationInfo>> success) Asynchronously retrieves a list ofConversationInfos for the accessible conversations that the user is a participant in.Returns the currently configured custom loading view creator.android.view.ViewReturns the Unblu UI component to interact with (chat, call, video, co-browsing) as aView.Returns the low-level notification API.io.reactivex.rxjava3.core.Observable<Optional<UnbluConversation>>Gets the current open conversation as anObservable.Gets the current open conversationReturns the information of the current person.intFetches the number of unread messagesvoidgetVisitorData(SuccessCallback<String> result) Retrieves visitor data for the active conversation.io.reactivex.rxjava3.core.Observable<Boolean>Fired when the call UI is open or closed.voidisCallUiOpen(SuccessCallback<Boolean> success, NotInitializedExceptionCallback failure) Checks whether the call UI for an audio or video call is open.booleanChecks if the UnbluClient instance is currently deinitializedbooleanChecks if the UnbluClient is in an eror state.io.reactivex.rxjava3.core.Observable<Boolean>Returns the a boolean flag, signaling if there is, or not, an ongoing cobrowsing session.io.reactivex.rxjava3.core.Observable<Boolean>Observe if the Unblu view is presented as a modal view and is visible or not.booleanChecks if the Unblu view is presented as a modal view and is visible or not.Fired when the UnbluClient is deInitialized.io.reactivex.rxjava3.core.Observable<List<ConversationInfo>>Returns anObservablethat emits a list ofConversationInfoobjects whenever there are changes to the accessible conversations the user is a participant in.io.reactivex.rxjava3.core.Observable<UnbluCustomConversationActionInvocation>Handles the invocation of custom actions related to a conversationio.reactivex.rxjava3.core.Observable<UnbluMessageCustomActionInvocation>Handles the invocation of custom actions related to a specific message in a conversationio.reactivex.rxjava3.core.Observable<Long>Checks for the UTC timestamp of the user's last activity according to the Collaboration Server's configurationio.reactivex.rxjava3.core.Observable<PersonInfo>Fired when the current person changesio.reactivex.rxjava3.core.Observable<UnbluPersonCustomActionInvocation>Handles the invocation of custom actions related to a personFired when the UI is preloaded.Fired when the UI is ready.io.reactivex.rxjava3.core.Observable<Integer>Fired when the number of unread messages changes, and if there are no longer any unread messages.voidopenConversation(String conversationId, SuccessVoidCallback success, OpenConversationExceptionCallback failure) Opens the conversation with the given IDvoidopenConversationOverview(SuccessVoidCallback success, OpenConversationOverviewExceptionCallback failure) Opens the conversation overviewvoidremovePersonLabel(String name, IPersonLabelActionCallback onResult) Removes a label from the current person.voidsetAccessToken(String token) Sets the OAuth 2.0 token to pass to the service worker and add to the HTTP headervoidSets anIndicatorButtonClickInterceptorto the client.voidsetActiveConversationIndicatorIcon(UnbluImageResourceWrapper indicatorIcon) Sets the icon used for the active conversation floating indicator within the application's user interface.voidsetApplicationContext(android.app.Application application) Sets the application context.voidsetAutoHideUiOnBack(boolean autoHideUiOnBack) If true, the Unblu UI is automatically hidden if the user presses the native back button and no further back navigation within the Unblu UI is possible.
The method has no effect if you added aBackButtonCallbackto handle back button presses by callingsetBackButtonCallback(com.unblu.sdk.core.callback.BackButtonCallback).voidsetBackButtonCallback(BackButtonCallback backButtonCallback) Defines the callback for native back button presses while the Unblu UI is displayed.
If it is null, the SDK will handle all back button presses itself.voidDefines the event type that triggers a back button pressvoidSets anIndicatorButtonClickInterceptorto the client.voidsetCustomCookies(Set<UnbluCookie> customCookies) Sets the given cookies for the configured Unblu base URL.voidsetCustomLoadingViewCreator(ICustomLoadingViewCreator customLoadingViewCreator) Sets a custom loading view creator.voidsetModalMode(Boolean modalMode) Manually set the unblu UI state as modal(no Unblu back button visible).voidsetModalViewEnabled(boolean enabled) Enables/Disables the Unblu view to be presented as a modal view.voidsetUnbluModaViewHandler(UnbluModalViewHandler unbluModaViewHandler) Defines the Handler for display Unblu as modal view
-
Method Details
-
deinitClient
void deinitClient(@Nullable SuccessVoidCallback success, @Nullable DeinitializeExceptionCallback failure) Deinitializes the UnbluClient.Calling this method frees all resources allocated by the UnbluClient.
This is an asynchronous call. Use the callbacks to check for success or failure.
Consecutive calls (without initializing inbetween) are ignored, but the callbacks are triggered as soon as there's a result.
- Parameters:
success- Optional callback that's called once the API has been deinitialized.failure- Optional callback that's called if the deinitialization of the API fails.
-
isInErrorState
boolean isInErrorState()Checks if the UnbluClient is in an eror state.This method doesn't provide a means to determine the error type. It's meant to be called as a precautionary measure, for example, before you attempt to use Unblu.
To determine the type of error, you must first register an
Observable.- Returns:
- true if the UnbluClient is in error state. false otherwise.
-
setCustomCookies
Sets the given cookies for the configured Unblu base URL.This will set additional cookies and will overwrite existing ones. If the UnbluClient instance was already initialized and cookies were already placed, the method overwrites cookies with the same key and adds any cookies with new keys. Existing cookies with other keys aren't affected.
To delete a cookie, it must be set with an expired date.
All cookies are removed when
deinitClient(SuccessVoidCallback, DeinitializeExceptionCallback)is called.Factory methods:
- Parameters:
customCookies- A Set ofUnbluCookiethat define the cookies to send to the configured base URL with each request
-
setAutoHideUiOnBack
void setAutoHideUiOnBack(boolean autoHideUiOnBack) If true, the Unblu UI is automatically hidden if the user presses the native back button and no further back navigation within the Unblu UI is possible.
The method has no effect if you added aBackButtonCallbackto handle back button presses by callingsetBackButtonCallback(com.unblu.sdk.core.callback.BackButtonCallback).- Parameters:
autoHideUiOnBack- true to enabled hiding the UI when the native back button is pressed, false to disable it
-
setBackButtonCallback
Defines the callback for native back button presses while the Unblu UI is displayed.
If it is null, the SDK will handle all back button presses itself. In this case it will navigate up inside the webView or, ifsetAutoHideUiOnBack(boolean)is true, it will hide the UI when the top level of the UI is reached.- Parameters:
backButtonCallback- The listener which handles the back button press
-
setBackButtonPressTriggerEvent
Defines the event type that triggers a back button press- Parameters:
event- The event on which to listen for the back button trigger. Possible values are UP and DOWN.
-
isCallUiOpen
void isCallUiOpen(@NonNull SuccessCallback<Boolean> success, @Nullable NotInitializedExceptionCallback failure) Checks whether the call UI for an audio or video call is open. If the call UI closed is minimized, the result is false.This is an asynchronous call. Use the callbacks to check for success or failure.
If you need to check whether a call is active, use the
CallModuleAPI.- Parameters:
success- Optional callback called with the result of the checkfailure- Optional callback called if the API wasn't initialized
-
openConversation
void openConversation(@NonNull String conversationId, @Nullable SuccessVoidCallback success, @Nullable OpenConversationExceptionCallback failure) Opens the conversation with the given ID- Parameters:
conversationId- The ID of the conversation to opensuccess- Called after the conversation was openedfailure- Called if there was an error opening the conversation
-
openConversationOverview
void openConversationOverview(@Nullable SuccessVoidCallback success, @Nullable OpenConversationOverviewExceptionCallback failure) Opens the conversation overview- Parameters:
success- Called if the overview was openedfailure- Called if there was an error opening the conversation overview
-
getUnreadMessagesCount
int getUnreadMessagesCount()Fetches the number of unread messages- Returns:
- The number of unread messages
-
getPersonInfo
Returns the information of the current person.If you're working with a
UnbluVisitorClientinstance, useUnbluVisitorClient.getPersonInfoAsync()instead. This ensures that there is a value present as due to some internal optimizations, this may not be the case, for example, if the UI has never been displayed.- Returns:
- A
PersonInfocontaining the current person's information
-
setCustomLoadingViewCreator
Sets a custom loading view creator.The default loading creator is a message with an animated ellipsis beneath it.
- Parameters:
customLoadingViewCreator- The loading view creator to use whenever a loading view is displayed
-
getCustomLoadingViewCreator
Returns the currently configured custom loading view creator. If the default loading view creator is used, the method returns null.- Returns:
- The current custom loading view creator or null if the default loading view creator is used
-
getNotificationApi
UnbluNotificationApi getNotificationApi()Returns the low-level notification API. This can be used if you don't use the Unblu Firebase notification module.- Returns:
- The
UnbluNotificationApiinstance
-
setApplicationContext
void setApplicationContext(@NonNull android.app.Application application) Sets the application context. This is only used internally; you shouldn't need to use it.- Parameters:
application- TheUnbluApplicationor a class which should inherit it.
-
onUnreadMessagesCount
io.reactivex.rxjava3.core.Observable<Integer> onUnreadMessagesCount()Fired when the number of unread messages changes, and if there are no longer any unread messages.- Returns:
Observablewhich emits anInteger
-
onPersonChanged
io.reactivex.rxjava3.core.Observable<PersonInfo> onPersonChanged()Fired when the current person changes- Returns:
Observablewhich emitsPersonInfo
-
getOpenConversation
io.reactivex.rxjava3.core.Observable<Optional<UnbluConversation>> getOpenConversation()Gets the current open conversation as anObservable. It always emits the current conversation. An empty Optional is emitted if there is no open conversation.- Returns:
Observablewhich emits the current open conversation, or an empty Optional if no conversation is open.
-
getOpenConversationValue
Gets the current open conversation- Returns:
UnbluConversationof the conversation currently open
-
isCallUiOpen
io.reactivex.rxjava3.core.Observable<Boolean> isCallUiOpen()Fired when the call UI is open or closed. Closed can mean there's no ongoing call or the call UI is minimmized. Check the instance for callActive to determine if a call is active or not.- Returns:
Observablewhich emits aBoolean
-
getMainView
android.view.View getMainView()Returns the Unblu UI component to interact with (chat, call, video, co-browsing) as aView. The View should work like any other widget extendingView, with the following exception:If the instance is attached to a view inside an
Activity, whenActivity.onDestroy()is called, this instance detaches itself from the parent.Note: If you attached to a
Viewinside anActivitywhose category in the manifest is "android.intent.category.LAUNCHER", you may not always get this behaviour, because these activities usually only get destroyed along with the application instance.Otherwise, if you intend to reuse the instance after it was attached to a
View, make sure you first remove the mainView from its parentViewor you will get the following error:IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.Example: When attaching the mainView inside a
Fragment, when the FragmentViewis destroyed, you should callViewGroup.removeView(View)from mainView's parent.You can achieve this by adding a
LifecycleObserverto theLifecyclein yourFragment:lifecycle.addObserver(LifecycleEventObserver { _, event -> if(event.targetState == Lifecycle.State.DESTROYED){ //remove mainView from its parent } })- Returns:
- the Unblu Ui
Viewinstance
-
onApiDeInitialized
Fired when the UnbluClient is deInitialized. This alerts you that the API can't be used.- Returns:
- an
Observablewhich emits on deinitialization
-
onUiReady
Fired when the UI is ready.- Returns:
- An
Observablethat emits once, when the UI is ready
-
onUiPreloaded
Fired when the UI is preloaded. This is the case when the UI is loaded without being displayed so the UI reacts more quickly when it should first be displayed.- Returns:
- An
Observablethat emits once, when the UI is preloaded
-
isDeInitialized
boolean isDeInitialized()Checks if the UnbluClient instance is currently deinitialized- Returns:
- true if the instance is deinitialized, false otherwise
-
onPersonActivityChanged
io.reactivex.rxjava3.core.Observable<Long> onPersonActivityChanged()Checks for the UTC timestamp of the user's last activity according to the Collaboration Server's configuration- Returns:
- an
Observablethat emits the last activity timestamp
-
setAccessToken
Sets the OAuth 2.0 token to pass to the service worker and add to the HTTP header- Parameters:
token- The token received from an identity provider
-
onCustomConversationActionInvocationReceived
io.reactivex.rxjava3.core.Observable<UnbluCustomConversationActionInvocation> onCustomConversationActionInvocationReceived()Handles the invocation of custom actions related to a conversation- Returns:
- Observable of
UnbluCustomConversationActionInvocation, the observable stream of custom conversation action invocations - See Also:
-
onPersonCustomActionInvocationReceived
io.reactivex.rxjava3.core.Observable<UnbluPersonCustomActionInvocation> onPersonCustomActionInvocationReceived()Handles the invocation of custom actions related to a person- Returns:
- Observable of
UnbluPersonCustomActionInvocation, the observable stream of custom person action invocations - See Also:
-
onMessageCustomActionInvocationReceived
io.reactivex.rxjava3.core.Observable<UnbluMessageCustomActionInvocation> onMessageCustomActionInvocationReceived()Handles the invocation of custom actions related to a specific message in a conversation- Returns:
- Observable of
UnbluMessageCustomActionInvocation, the observable stream of custom message action invocations - See Also:
-
getConversations
Asynchronously retrieves a list ofConversationInfos for the accessible conversations that the user is a participant in. This method provides the results through a callback that is invoked upon the successful fetching of the data.- Parameters:
success- ASuccessCallbackthat is called with the list ofConversationInfowhen the data is successfully retrieved.
-
onConversationsChanged
io.reactivex.rxjava3.core.Observable<List<ConversationInfo>> onConversationsChanged()Returns anObservablethat emits a list ofConversationInfoobjects whenever there are changes to the accessible conversations the user is a participant in.- Returns:
- an observable stream of
ConversationInfodata.
-
addPersonLabel
Adds a label to the current person. This method is only compatible with version 8.0.0 or newer of the Collaboration Server.- Parameters:
name- The name of the label to addonResult- AIPersonLabelActionCallbackthat reports either success viaIPersonLabelActionCallback.onSuccess()or failure viaIPersonLabelActionCallback.onError(UnbluClientErrorType, String). Using this method with older Unblu server versions results in a callback call forIPersonLabelActionCallbackwith the valueUnbluClientErrorType.UNSUPPORTED_VERSION.
-
removePersonLabel
Removes a label from the current person. This method is only compatible with version 8.0.0 or newer of the Collaboration Server.- Parameters:
name- The name of the label to removeonResult- AIPersonLabelActionCallbackthat reports either success viaIPersonLabelActionCallback.onSuccess()or failure viaIPersonLabelActionCallback.onError(UnbluClientErrorType, String). Using this method with older Unblu server versions results in a callback call forIPersonLabelActionCallbackwith the valueUnbluClientErrorType.UNSUPPORTED_VERSION.
-
isModalViewVisible
io.reactivex.rxjava3.core.Observable<Boolean> isModalViewVisible()Observe if the Unblu view is presented as a modal view and is visible or not. -
isModalViewVisibleValue
boolean isModalViewVisibleValue()Checks if the Unblu view is presented as a modal view and is visible or not. -
setModalViewEnabled
void setModalViewEnabled(boolean enabled) Enables/Disables the Unblu view to be presented as a modal view.Enabling this will also enable a dragabble floating avatar/pip widget on the UI, to trigger the modal view
-
setUnbluModaViewHandler
Defines the Handler for display Unblu as modal view- Parameters:
unbluModaViewHandler- the view handler
-
setModalMode
Manually set the unblu UI state as modal(no Unblu back button visible). If you intend to have default behaviour, set this back to false.- Parameters:
modalMode- flag
-
setActiveConversationIndicatorButtonClickInterceptor
void setActiveConversationIndicatorButtonClickInterceptor(@Nullable IndicatorButtonClickInterceptor interceptor) Sets anIndicatorButtonClickInterceptorto the client.The interceptor is called when the user clicks on the active conversation indicator button.
- Parameters:
interceptor- The interceptor to set
-
setCollapseUIButtonClickInterceptor
Sets anIndicatorButtonClickInterceptorto the client.The interceptor is called when the user clicks on the collapse button in the Unblu UI.
- Parameters:
interceptor- The interceptor to set
-
setActiveConversationIndicatorIcon
Sets the icon used for the active conversation floating indicator within the application's user interface. This method allows customization of the floating indicator's appearance by specifying an icon wrapped in anUnbluImageResourceWrapper, which can encapsulate various types of image resources, including drawables, ImageVector objects and URLs.Hint: When using a URL resource, provide a square image to ensure the icon's displayed correctly.
- Parameters:
indicatorIcon- An instance ofUnbluImageResourceWrapperrepresenting the new icon to be used for the floating indicator.
-
isMobileCoBrowsing
io.reactivex.rxjava3.core.Observable<Boolean> isMobileCoBrowsing()Returns the a boolean flag, signaling if there is, or not, an ongoing cobrowsing session.- Returns:
- boolean flag wrapped in a Observable
-
getVisitorData
Retrieves visitor data for the active conversation.- Parameters:
result- ASuccessCallbackthat is called with the visitor data when the data is successfully retrieved.
-