Interface UnbluClient

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

        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<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 check
        failure - 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 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<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 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<java.util.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<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 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<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