Interface UnbluClient
-
- All Known Subinterfaces:
UnbluAgentClient
,UnbluVisitorClient
public interface UnbluClient
Common interface for Unblu clients. For more information, refer to the implementation classesUnbluAgentClient
andUnbluVisitorClient
.Minumum requirements:
Android API version 24
Unblu Collaboration Server 6.33.x or newer
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
deinitClient(SuccessVoidCallback success, DeinitializeExceptionCallback failure)
Deinitializes the UnbluClient.ICustomLoadingViewCreator
getCustomLoadingViewCreator()
Returns the currently configured custom loading view creator.android.view.View
getMainView()
Returns the Unblu UI component to interact with (chat, call, video, co-browsing) as aView
.UnbluNotificationApi
getNotificationApi()
Returns the low-level notification API.io.reactivex.rxjava3.core.Observable<java.util.Optional<UnbluConversation>>
getOpenConversation()
Gets the current open conversation as anObservable
.UnbluConversation
getOpenConversationValue()
Gets the current open conversationPersonInfo
getPersonInfo()
Returns the information of the current person.int
getUnreadMessagesCount()
Fetches the number of unread messagesio.reactivex.rxjava3.core.Observable<java.lang.Boolean>
isCallUiOpen()
Fired when the call UI is open or closed.void
isCallUiOpen(SuccessCallback<java.lang.Boolean> success, NotInitializedExceptionCallback failure)
Checks whether the call UI for an audio or video call is open.boolean
isDeInitialized()
Checks if the UnbluClient instance is currently deinitializedboolean
isInErrorState()
Checks if the UnbluClient is in an eror state.io.reactivex.rxjava3.core.Observable<java.util.Optional<java.lang.Void>>
onApiDeInitialized()
Fired when the UnbluClient is deInitialized.io.reactivex.rxjava3.core.Observable<UnbluCustomConversationActionInvocation>
onCustomConversationActionInvocationReceived()
Handles the invocation of custom actions related to a conversationio.reactivex.rxjava3.core.Observable<UnbluMessageCustomActionInvocation>
onMessageCustomActionInvocationReceived()
Handles the invocation of custom actions related to a specific message in a conversationio.reactivex.rxjava3.core.Observable<java.lang.Long>
onPersonActivityChanged()
Checks for the UTC timestamp of the user's last activity according to the Collaboration Server's configurationio.reactivex.rxjava3.core.Observable<PersonInfo>
onPersonChanged()
Fired when the current person changesio.reactivex.rxjava3.core.Observable<UnbluPersonCustomActionInvocation>
onPersonCustomActionInvocationReceived()
Handles the invocation of custom actions related to a personio.reactivex.rxjava3.core.Observable<java.util.Optional<java.lang.Void>>
onUiPreloaded()
Fired when the UI is preloaded.io.reactivex.rxjava3.core.Observable<java.util.Optional<java.lang.Void>>
onUiReady()
Fired when the UI is ready.io.reactivex.rxjava3.core.Observable<java.lang.Integer>
onUnreadMessagesCount()
Fired when the number of unread messages changes, and if there are no longer any unread messages.void
openConversation(java.lang.String conversationId, SuccessVoidCallback success, OpenConversationExceptionCallback failure)
Opens the conversation with the given IDvoid
openConversationOverview(SuccessVoidCallback success, OpenConversationOverviewExceptionCallback failure)
Opens the conversation overviewvoid
setAccessToken(java.lang.String token)
Sets the OAuth 2.0 token to pass to the service worker and add to the HTTP headervoid
setApplicationContext(android.app.Application application)
Sets the application context.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 aBackButtonCallback
to handle back button presses by callingsetBackButtonCallback(com.unblu.sdk.core.callback.BackButtonCallback)
.void
setBackButtonCallback(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.void
setBackButtonPressTriggerEvent(BackButtonPressTriggerEvent event)
Defines the event type that triggers a back button pressvoid
setCustomCookies(java.util.Set<UnbluCookie> customCookies)
Sets the given cookies for the configured Unblu base URL.void
setCustomLoadingViewCreator(ICustomLoadingViewCreator customLoadingViewCreator)
Sets a custom loading view creator.
-
-
-
Method Detail
-
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
void setCustomCookies(@NonNull java.util.Set<UnbluCookie> customCookies)
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 ofUnbluCookie
that 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 aBackButtonCallback
to 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
void setBackButtonCallback(@Nullable 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. 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
void setBackButtonPressTriggerEvent(@NonNull BackButtonPressTriggerEvent event)
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<java.lang.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
CallModule
API.- Parameters:
success
- Optional callback called with the result of the checkfailure
- Optional callback called if the API wasn't initialized
-
openConversation
void openConversation(@NonNull java.lang.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
@Nullable PersonInfo getPersonInfo()
Returns the information of the current person.If you're working with a
UnbluVisitorClient
instance, 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
PersonInfo
containing the current person's information
-
setCustomLoadingViewCreator
void setCustomLoadingViewCreator(@Nullable ICustomLoadingViewCreator customLoadingViewCreator)
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
@Nullable ICustomLoadingViewCreator 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
UnbluNotificationApi
instance
-
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
- TheUnbluApplication
or a class which should inherit it.
-
onUnreadMessagesCount
io.reactivex.rxjava3.core.Observable<java.lang.Integer> onUnreadMessagesCount()
Fired when the number of unread messages changes, and if there are no longer any unread messages.- Returns:
Observable
which emits anInteger
-
onPersonChanged
io.reactivex.rxjava3.core.Observable<PersonInfo> onPersonChanged()
Fired when the current person changes- Returns:
Observable
which emitsPersonInfo
-
getOpenConversation
io.reactivex.rxjava3.core.Observable<java.util.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:
Observable
which emits the current open conversation, or an empty Optional if no conversation is open.
-
getOpenConversationValue
@Nullable UnbluConversation getOpenConversationValue()
Gets the current open conversation- Returns:
UnbluConversation
of the conversation currently open
-
isCallUiOpen
io.reactivex.rxjava3.core.Observable<java.lang.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:
Observable
which 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
View
inside anActivity
whose 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 parentView
or 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 FragmentView
is destroyed, you should callViewGroup.removeView(View)
from mainView's parent.You can achieve this by adding a
LifecycleObserver
to theLifecycle
in yourFragment
:lifecycle.addObserver(LifecycleEventObserver { _, event -> if(event.targetState == Lifecycle.State.DESTROYED){ //remove mainView from its parent } })
- Returns:
- the Unblu Ui
View
instance
-
onApiDeInitialized
io.reactivex.rxjava3.core.Observable<java.util.Optional<java.lang.Void>> onApiDeInitialized()
Fired when the UnbluClient is deInitialized. This alerts you that the API can't be used.- Returns:
- an
Observable
which emits on deinitialization
-
onUiReady
io.reactivex.rxjava3.core.Observable<java.util.Optional<java.lang.Void>> onUiReady()
Fired when the UI is ready.- Returns:
- An
Observable
that emits once, when the UI is ready
-
onUiPreloaded
io.reactivex.rxjava3.core.Observable<java.util.Optional<java.lang.Void>> 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
Observable
that 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<java.lang.Long> onPersonActivityChanged()
Checks for the UTC timestamp of the user's last activity according to the Collaboration Server's configuration- Returns:
- an
Observable
that emits the last activity timestamp
-
setAccessToken
void setAccessToken(java.lang.String token)
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:
UnbluCustomConversationActionInvocation
-
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:
UnbluPersonCustomActionInvocation
-
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:
UnbluMessageCustomActionInvocation
-
-