Interface UnbluClient

All Known Subinterfaces:
UnbluAgentClient, UnbluVisitorClient

public interface UnbluClient
Common interface for Unblu clients. For more information, refer to the implementation classes UnbluAgentClient and UnbluVisitorClient.

Minumum requirements:

Android API version 24

Unblu Collaboration Server 6.33.x or newer

  • 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

      void setCustomCookies(@NonNull 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:

      UnbluCookie.from(List)

      UnbluCookie.from(Map)

      Parameters:
      customCookies - A Set of UnbluCookie 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 a BackButtonCallback to handle back button presses by calling setBackButtonCallback(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, if setAutoHideUiOnBack(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<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 check
      failure - 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 open
      success - Called after the conversation was opened
      failure - 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 opened
      failure - 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, use UnbluVisitorClient.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 - The UnbluApplication or 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:
      Observable which emits an Integer
    • onPersonChanged

      io.reactivex.rxjava3.core.Observable<PersonInfo> onPersonChanged()
      Fired when the current person changes
      Returns:
      Observable which emits PersonInfo
    • getOpenConversation

      io.reactivex.rxjava3.core.Observable<Optional<UnbluConversation>> getOpenConversation()
      Gets the current open conversation as an Observable. 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<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 a Boolean
    • getMainView

      android.view.View getMainView()
      Returns the Unblu UI component to interact with (chat, call, video, co-browsing) as a View. The View should work like any other widget extending View, with the following exception:

      If the instance is attached to a view inside an Activity, when Activity.onDestroy() is called, this instance detaches itself from the parent.

      Note: If you attached to a View inside an Activity 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 parent View 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 Fragment View is destroyed, you should call ViewGroup.removeView(View) from mainView's parent.

      You can achieve this by adding a LifecycleObserver to the Lifecycle in your Fragment:

       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<Optional<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<Optional<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<Optional<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<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(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:
    • 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

      void getConversations(@NonNull SuccessCallback<List<ConversationInfo>> success)
      Asynchronously retrieves a list of ConversationInfos 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 - A SuccessCallback that is called with the list of ConversationInfo when the data is successfully retrieved.
    • onConversationsChanged

      io.reactivex.rxjava3.core.Observable<List<ConversationInfo>> onConversationsChanged()
      Returns an Observable that emits a list of ConversationInfo objects whenever there are changes to the accessible conversations the user is a participant in.
      Returns:
      an observable stream of ConversationInfo data.
    • addPersonLabel

      void addPersonLabel(String name, IPersonLabelActionCallback onResult)
      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 add
      onResult - A IPersonLabelActionCallback that reports either success via IPersonLabelActionCallback.onSuccess() or failure via IPersonLabelActionCallback.onError(UnbluClientErrorType, String). Using this method with older Unblu server versions results in a callback call for IPersonLabelActionCallback with the value UnbluClientErrorType.UNSUPPORTED_VERSION.
    • removePersonLabel

      void removePersonLabel(String name, IPersonLabelActionCallback onResult)
      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 remove
      onResult - A IPersonLabelActionCallback that reports either success via IPersonLabelActionCallback.onSuccess() or failure via IPersonLabelActionCallback.onError(UnbluClientErrorType, String). Using this method with older Unblu server versions results in a callback call for IPersonLabelActionCallback with the value UnbluClientErrorType.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

      void setUnbluModaViewHandler(@Nullable UnbluModalViewHandler unbluModaViewHandler)
      Defines the Handler for display Unblu as modal view
      Parameters:
      unbluModaViewHandler - the view handler
    • setModalMode

      void setModalMode(@Nullable Boolean modalMode)
      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 an IndicatorButtonClickInterceptor to the client.

      The interceptor is called when the user clicks on the active conversation indicator button.

      Parameters:
      interceptor - The interceptor to set
    • setCollapseUIButtonClickInterceptor

      void setCollapseUIButtonClickInterceptor(@Nullable IndicatorButtonClickInterceptor interceptor)
      Sets an IndicatorButtonClickInterceptor to the client.

      The interceptor is called when the user clicks on the collapse button in the Unblu UI.

      Parameters:
      interceptor - The interceptor to set