Skip navigation links
com.unblu.sdk.core

Class UnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>

    • Field Detail

      • enableDebugOutput

        public static boolean enableDebugOutput
        Enables the debug output of the Unblu SDK. This contains additional information on log messages and is independent of the log level defined with setLogLevel(LogLevel).
      • enableCapturingPerformanceLogging

        public static boolean enableCapturingPerformanceLogging
        Enables logging of capturing performance (e.g. FPS)

        IMPORTANT: This only has effect, if enableDebugOutput is set to true and the log level is set to LogLevel.DEBUG via setLogLevel(LogLevel)!

      • ANIMATION_TIME

        public static final long ANIMATION_TIME
        The time used for the fade in and fade out animation when showing/hiding the UI
        See Also:
        Constant Field Values
    • Constructor Detail

      • UnbluCoreApi

        protected UnbluCoreApi(T apiDelegate)
    • Method Detail

      • internalGetCoreInstance

        public static <D extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate> UnbluCoreApi<D> internalGetCoreInstance()
        Type Parameters:
        D - class
        Returns:
        The instance of the UnbluCoreApi. Only for internal use!
        Throws:
        java.lang.IllegalStateException - If the core api was not initialized by either using UnbluVisitorApi or UnbluAgentApi
      • setLogLevel

        public static void setLogLevel(LogLevel logLevel)
        Sets the log level of the Unblu SDK. All messages with a lower level will not be logged.
        Default is LogLevel.VERBOSE as in release builds the verbose and debug logs are stripped out via proguard.
        Parameters:
        logLevel - Level which should be set
        See Also:
        getLogLevel()
      • getLogLevel

        public static LogLevel getLogLevel()
        Returns the log level of the Unblu SDK. All messages with a lower level will not be logged
        Returns:
        the log level of the Unblu SDK. All messages with a lower level will not be logged
        See Also:
        setLogLevel(LogLevel)
      • getApplication

        public android.app.Application getApplication()
        Returns the application context object
        Overrides:
        getApplication in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Returns:
        The application context object
      • configureApi

        public void configureApi(UnbluApiConfiguration configuration)
        Configures the unblu api. Use initApi(IUnbluApiSuccessfullyInitializedCallback, IUnbluApiInitializeExceptionCallback) to be able start new conversation and use other API features.

        Note:

        • This should only be called once with the correct configuration.
        • This method should be called from the application function of the AppDelegate class.
        Overrides:
        configureApi in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Parameters:
        configuration - The configuration for the unblu api
        Throws:
        java.lang.IllegalStateException - Thrown if the api was already initialized. The api needs to be deinitialized to configure it.
      • initApi

        public void initApi(@Nullable
                            IUnbluApiSuccessfullyInitializedCallback success,
                            @Nullable
                            IUnbluApiInitializeExceptionCallback failure)
        Inits the unblu API.

        This is an asynchronous call. Any further calls can be done inside the success callback or after the IUnbluEventApi.ApiIsInitialized event.

        Connects to the unblu server and makes the API ready for further calls.

        Consecutive calls (without deinitializing in between) will be ignored, but the callbacks will also be triggered, as soon as there is a result.

        Overrides:
        initApi in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Parameters:
        success - Optional callback that will be called once the API has been successfully initialized and also provides a callback if the pre loading chat ui was loaded (if preloading was enabled)
        failure - Optional callback that will be called if the initialization of the API fails.
      • initApi

        public void initApi(@NonNull
                            android.app.Activity activeActivity,
                            @Nullable
                            IUnbluApiSuccessfullyInitializedCallback success,
                            @Nullable
                            IUnbluApiInitializeExceptionCallback failure)
        Inits the unblu API.

        This is an asynchronous call. Any further calls can be done inside the success callback or after the IUnbluEventApi.ApiIsInitialized event.

        Connects to the unblu server and makes the API ready for further calls.

        Consecutive calls (without deinitializing in between) will be ignored, but the callbacks will also be triggered, as soon as there is a result.

        Use this method if you are NOT extending your Application class after UnbluCoreApplication or a class which should inherit it and also if you are NOT using the UnbluApplicationHelper

        Overrides:
        initApi in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Parameters:
        activeActivity - the Activity which is currently active so it can bind the UnbluUI.
        success - Optional callback that will be called once the API has been successfully initialized and also provides a callback if the pre loading chat ui was loaded (if preloading was enabled)
        failure - Optional callback that will be called if the initialization of the API fails.
      • deinitApi

        public void deinitApi(@Nullable
                              IUnbluApiSuccessVoidCallback success,
                              @Nullable
                              IUnbluDeinitializeExceptionCallback failure)
        Deinitializes the unblu API.

        This is an asynchronous call. Use the callbacks to check for success / failure.

        Calling this method will free all resources allocated by the unblu API.

        Consecutive calls (without initializing in between) will be ignored, but the callbacks will also be triggered, as soon as there is a result.

        Overrides:
        deinitApi in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Parameters:
        success - Optional callback that will be called once the API has been successfully deinitialized.
        failure - Optional callback that will be called if the deinitialization of the API fails.
      • isInitialized

        public boolean isInitialized()
        Overrides:
        isInitialized in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Returns:
        true if the API was initialized and the initialization of the API was successful. false if api is not initialized or in error state.
      • isInErrorState

        public boolean isInErrorState()
        Overrides:
        isInErrorState in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Returns:
        true if the API is in error state. false otherwise.
      • preloadUi

        public void preloadUi(@Nullable
                              IUnbluApiSuccessVoidCallback success,
                              @Nullable
                              IUnbluApiNotInitializedExceptionCallback failure)
        Starts pre loading the chat ui. Can be called as soon as the api is initialized. It will load the page, which is needed later for chat.
        If preloadChatUiAfterApiInitEnabled of configureApi(UnbluApiConfiguration) is set to true, this call is not needed

        This is an asynchronous call. Use the callbacks to check for success / failure.

        Overrides:
        preloadUi in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Parameters:
        success - Optional callback that will be called once the preloading is finished.
        failure - Optional callback that will be called if the api was not initialized.
      • setAutoHideUiOnBack

        public void setAutoHideUiOnBack(boolean autoHideUiOnBack)
        If set to true, the unblu UI will hide automatically if the user presses the back button and there is no more navigation inside the unblu UI.
        Also this option has no effect if there is a IBackButtonCallback configured which handles the back presses by itself.
        Overrides:
        setAutoHideUiOnBack in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Parameters:
        autoHideUiOnBack - True to enabled hiding the UI when back button is pressed, false to disable it
      • setBackButtonCallback

        public void setBackButtonCallback(@Nullable
                                          IBackButtonCallback backButtonCallback)
        Defines the callback for 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.
        Overrides:
        setBackButtonCallback in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Parameters:
        backButtonCallback - The listener which handles the back button press
      • isCallUiOpen

        public void isCallUiOpen(@NonNull
                                 IUnbluApiSuccessCallback<java.lang.Boolean> success,
                                 @Nullable
                                 IUnbluApiNotInitializedExceptionCallback failure)
        Checks if the call UI for an audio/video call is open or not. If the call UI is minimized, the result is also false.
        If you need to check if a call is active or not, use the call module api.
        This is an asynchronous call. Use the callbacks to check for success / failure.
        Overrides:
        isCallUiOpen in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Parameters:
        success - Optional callback that will be called with the result if the UI is open or not
        failure - Optional callback that will be called if the api was not initialized
      • showUi

        public void showUi(boolean show,
                           @Nullable
                           IUnbluApiSuccessVoidCallback success,
                           @Nullable
                           IUnbluShowUiExceptionCallback failure)
        This will show/hide the UI.
        This will animate the show/hide of the UI.
        Parameters:
        show - True to show the UI. False to hide it.
        success - Called after the UI is shown/hidden. Triggered after the animation.
        failure - Called if there is an issue showing the UI
      • showUi

        public void showUi(boolean show,
                           boolean animate,
                           @Nullable
                           IUnbluApiSuccessVoidCallback success,
                           @Nullable
                           IUnbluShowUiExceptionCallback failure)
        This will show/hide the UI.
        Overrides:
        showUi in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Parameters:
        show - True to show the UI. False to hide it.
        animate - True to animation the show/hide of the UI.
        success - Called after the UI is shown/hidden. Triggered after the animation.
        failure - Called if there is an issue showing the UI
      • isUiVisible

        public boolean isUiVisible()
        Checks if the UI is visible or not
        Overrides:
        isUiVisible in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Returns:
        True if the UI is visible. False otherwise
      • setUiMargins

        public void setUiMargins(int top,
                                 int bottom)
        Sets a margins of the UI.
        This can be used, if there should be a an open/close fab button or some menu at the top.
        The top margin starts bellow the status bar.
        The bottom margin starts above the navigation bar, if navigation bar is visible. Otherwise it is from the bottom of the screen (navigation bar is transparent above the content or gesture navigation is used.
        Overrides:
        setUiMargins in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Parameters:
        top - The amount of margin in pixel at the top
        bottom - The amount of margin in pixel at the bottom
      • getUiTopMargin

        public int getUiTopMargin()
        Returns the current top margin of the unblu Ui
        Overrides:
        getUiTopMargin in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Returns:
        The current top margin of the unblu Ui
      • getUiBottomMargin

        public int getUiBottomMargin()
        Returns the current bottom margin of the unblu Ui
        Overrides:
        getUiBottomMargin in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Returns:
        The current bottom margin of the unblu Ui
      • openConversation

        public void openConversation(@NonNull
                                     java.lang.String conversationId,
                                     @Nullable
                                     IUnbluApiSuccessVoidCallback success,
                                     @Nullable
                                     IUnbluApiOpenConversationExceptionCallback failure)
        Opens the conversation for the given id.
        The unblu UI must have been visible at least once. You can call this after a call to showUi(boolean, IUnbluApiSuccessVoidCallback, IUnbluShowUiExceptionCallback) (wait for the success callback).
        Overrides:
        openConversation in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Parameters:
        conversationId - The id of the conversation which should be opened.
        success - Called after the conversation was opened
        failure - Called if there was an error opening the conversation
      • startAudioCall

        public void startAudioCall(@NonNull
                                   java.lang.String conversationId,
                                   @Nullable
                                   IUnbluApiSuccessVoidCallback success,
                                   @Nullable
                                   IUnbluApiStartAudioCallExceptionCallback failure)
        Opens a conversation for the given conversation id and starts an audio call.
        The unblu UI must have been visible at least once. You can call this after a call to showUi(boolean, IUnbluApiSuccessVoidCallback, IUnbluShowUiExceptionCallback) (wait for the success callback).
        Overrides:
        startAudioCall in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Parameters:
        conversationId - The id of the conversation in which the audio call should be started
        success - Called after the conversation was opened and the call has been started
        failure - Called if there was an error opening the conversation and starting the call
      • startVideoCall

        public void startVideoCall(@NonNull
                                   java.lang.String conversationId,
                                   @Nullable
                                   IUnbluApiSuccessVoidCallback success,
                                   @Nullable
                                   IUnbluApiStartVideoCallExceptionCallback failure)
        Opens a conversation for the given conversation id and starts a video call.
        The unblu UI must have been visible at least once. You can call this after a call to showUi(boolean, IUnbluApiSuccessVoidCallback, IUnbluShowUiExceptionCallback) (wait for the success callback).
        Overrides:
        startVideoCall in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Parameters:
        conversationId - The id of the conversation in which the video call should be started.
        success - Called after the conversation was opened and the call has been started
        failure - Called if there was an error opening the conversation and starting the call
      • getOpenConversationId

        @Nullable
        public java.lang.String getOpenConversationId()
        Returns the id of the currently opened conversation inside the UI.
        Null if no conversation is open
        Overrides:
        getOpenConversationId in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Returns:
        The id of the currently opened conversation or null
        Throws:
        java.lang.IllegalStateException - if the API is not initialized or if the UI was never shown.
      • getUnreadMessagesCount

        public int getUnreadMessagesCount()
        Returns the number of unread messages
        Overrides:
        getUnreadMessagesCount in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Returns:
        the number of unread messages
      • getPersonInfo

        @Nullable
        public PersonInfo getPersonInfo()
        Returns the info of the current person
        Overrides:
        getPersonInfo in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Returns:
        the info of the current person
        Throws:
        java.lang.IllegalStateException - if the API is not initialized
        UnsupportedCollaborationServerVersionException - if the used collaboration server is not of version 5.x newer than 5.17 or newer than 6.3
      • setCustomLoadingViewCreator

        public void setCustomLoadingViewCreator(@Nullable
                                                IUnbluCustomLoadingViewCreator customLoadingViewCreator)
        Sets a custom loading view creator.
        Overrides:
        setCustomLoadingViewCreator in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Parameters:
        customLoadingViewCreator - The loading view creator which should be used whenever a loading view is displayed
      • getCustomLoadingViewCreator

        @Nullable
        public IUnbluCustomLoadingViewCreator getCustomLoadingViewCreator()
        Returns the currently configured loading view creator
        Overrides:
        getCustomLoadingViewCreator in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Returns:
        the currently configured loadingView creator
      • getNotificationApi

        @NonNull
        public static IUnbluNotificationApi getNotificationApi()
        Returns the low level notification API which can be used if the unblu firebase notification module is not used.
        Returns:
        The notification api instance
      • setApplicationContext

        public void setApplicationContext(@NonNull
                                          android.app.Application application)
        Set the application. This is only for internal purpose
        Parameters:
        application - The UnbluCoreApplication or a class which should inherit it.
      • setNamedArea

        public void setNamedArea(java.lang.String namedArea)
        Sets or updates the named area. This can be called independent of the state of the api, but has different effects depending on the current state. If the api is not initialized when calling this function, the configuration of the named area is loaded as soon as the api gets initialized. If this function is called and the api is already initialized, it can only be used on the agent desk to filter incoming requests in the queue. No specific configuration is loaded for it. If a conversation is already active, this function has no effect until the api is either initialized again (what would load the configuration of the named area) or a new conversation is started (filtering named area in the queue).
        Overrides:
        setNamedArea in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Parameters:
        namedArea - The named area meta tag id which is configured on the agent desk.
      • setCustomBackgroundColor

        public void setCustomBackgroundColor(@ColorRes
                                             java.lang.Integer customBackgroundColor)
        Sets the background color for the Unblu UI. Per default this is transparent.
        Overrides:
        setCustomBackgroundColor in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
        Parameters:
        customBackgroundColor - The background color resource