UnbluClient

public protocol UnbluClient : AnyObject

A protocol describing functionality of the UnbluClient.

  • The view into which Unblu content will be rendered.

    Declaration

    Swift

    var view: UnbluView { get }
  • Enables the debug output of the Unblu SDK. This contains additional information on log messages and is independent of the log level defined with logLevel.

    Declaration

    Swift

    var enableDebugOutput: Bool { get set }
  • Defines the log level of the Unblu SDK. Messages with a lower level will not be logged.

    The default value is LogLevel.info.

    Declaration

    Swift

    var logLevel: LogLevel { get set }
  • Stops the UI from scrolling when the keyboard is shown or hidden.

    This setting should only be changed if it causes issues. If it is disabled, the user of the SDK has to ensure that the UI container/the webview inside is resized correctly when necessary.

    Declaration

    Swift

    var preventScrollingByKeyboard: Bool { get set }
  • Custom loading view creator used whenever a loading view is displayed.

    Declaration

    Swift

    var customLoadingViewCreator: UnbluCustomLoadingViewCreator? { get set }
  • Sets or updates the named area. This can be done independently of the state of the client, but it has a different effect depending on the current client state.

    • If the client has not been started when you set the named area, the configuration of the named area is loaded as soon as the client is started.
    • If you set the named area and the client has already been started, it can only be used on the Agent Desk to filter incoming requests in the queue. No specific configuration will be loaded for the named area.
    • If a conversation is already open, setting the named area has no effect until one of two events occur:
      • The UnbluClient is started again, which loads the configuration of the named area.
      • A new conversation is started, which results in the queue being filtered by the newly set named area

    Declaration

    Swift

    var namedArea: String? { get set }
  • Sets or updates custom cookies. When set, the UnbluCookie objects are passed to the Unblu WebView, which then uses them in future network requests. This can be done independently of the client’s current state. If the client has already been started, setting customCookies overwrites any existing cookies with the same key in the WebView. The other cookies are not affected. Cookies set here will be used by the WebView whether it’s waiting to be started or already running.

    Declaration

    Swift

    var customCookies: Set<UnbluCookie> { get set }
  • The current displayed UnbluConversation, or nil if there is no conversation currently displayed.

    Declaration

    Swift

    var openConversation: UnbluConversation? { get }
  • The current unread messages count

    Declaration

    Swift

    var unreadMessagesCount: Int { get }
  • Initializes the Unblu client.

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

    This is an asynchronous call. Any further calls can be made in the success callback or after receiving the ApiIsInitialized notification.

    Subsequent calls without deinitialization beforehand will be ignored. The callbacks, however, will be triggered as soon as there is a Result.

    Declaration

    Swift

    func start(_ completion: @escaping (Result<Void, UnbluClientInitializeError>) -> Void)

    Parameters

    completion

    The callback that will be called with a Result type once the client has been initialized successfully, or with an UnbluApiInitializeError if initialization failed.

  • Initializes the Unblu client.

    Connects to the unblu server and makes the API ready for further calls then tries to open a conversation with the passed id

    This is an asynchronous call. Any further calls can be made in the success callback or after receiving the ApiIsInitialized notification.

    Subsequent calls without deinitialization beforehand will be ignored. The callbacks, however, will be triggered as soon as there is a Result.

    Declaration

    Swift

    func start(with conversationId: String, _ completion: @escaping (Result<Void, UnbluClientInitializeError>, Result<UnbluConversation, UnbluOpenConversationError>) -> Void)

    Parameters

    conversationId

    The conversation id to open

    completion

    The callback that will be called with a Result type once the client has been initialized successfully, or with an UnbluApiInitializeError if initialization failed. The Second result containing the UnbluConversation that was opened, or an UnbluApiOpenConversationError if opening failed.

  • Deinitializes the Unblu client.

    Calling this method will free all resources allocated to the Unblu client.

    This is an asynchronous call. Use the callback to check for success or failure.

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

    Note

    This function invokes a full deinitialization, which is responsible for cleaning up the application state and freeing up resources. It also disconnects from the Collaboration Server properly. As a result, the function may take up to five seconds to complete, depending on the user’s network connection.

    Declaration

    Swift

    func stop(_ completion: ((Result<Void, UnbluDeinitializeError>) -> Void)?)

    Parameters

    completion

    completion: The (optional) callback that will be called with a Result type once the Unblu client has been deinitialized successfully, or with an UnbluApiDeinitializeError if deinitialization failed.

  • Returns true if the Unblu client was initialized and the initialization was successful, and false if the Unblu client is not initialized or is in an error state.

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

    Declaration

    Swift

    func isInitialized(success: @escaping (Bool) -> Void)

    Parameters

    success

    The callback called with true if the Unblu client is initialized and with false otherwise.

  • Returns true if the client is in error state, and false otherwise.

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

    Declaration

    Swift

    func isInErrorState(success: @escaping (Bool) -> Void)

    Parameters

    success

    The callback called with true if the Unblu client is in an error state and with false otherwise.

  • Opens and displays a conversation with the given ID in the UnbluView.

    Declaration

    Swift

    func openConversation(_ conversationId: String, onComplete: @escaping (Result<UnbluConversation, UnbluOpenConversationError>) -> Void)

    Parameters

    conversationId

    The ID of the conversation to open.

    onComplete

    A Result containing the UnbluConversation that was opened, or an UnbluApiOpenConversationError if opening failed.

  • Opens the conversation overview.

    Declaration

    Swift

    func openConversationOverview(onComplete: @escaping (Result<Void, UnbluOpenConversationOverviewError>) -> Void)

    Parameters

    onComplete

    A Result representing success if the conversation overview was opened, or an UnbluApiOpenConversationOverviewError if opening the overview failed.

  • Returns the information on the person currently interacting with the Unblu client.

    Declaration

    Swift

    func getPersonInfo(onComplete: @escaping (Result<PersonInfo, UnbluRetrievePersonInfoError>) -> Void)

    Parameters

    onComplete

    A Result containing the current PersonInfo of the person currently identified, or an UnbluApiRetrievePersonInfoError if retrieving the person’s information failed.

  • Set the OAuth 2.0 token to pass to service worker and used in the authorization header. Bearer Token Usage: https://datatracker.ietf.org/doc/html/rfc6750

    Declaration

    Swift

    func setOAuthToken(token: String)

    Parameters

    token

    The token received from an identity provider

  • Adds a label to the current person.

    This method is only compatible with version 8.0.0 or newer of the Collaboration Server.

    Declaration

    Swift

    func addPersonLabel(name: String, onComplete: @escaping (_ result: Bool) -> Void)

    Parameters

    name

    The name of the label to add

    result

    Reporting success with true or false to indicate whether the operation was successful or not.

  • Removes a label from the current person.

    This method is only compatible with version 8.0.0 or newer of the Collaboration Server.

    Declaration

    Swift

    func removePersonLabel(name: String, onComplete: @escaping (_ result: Bool) -> Void)

    Parameters

    name

    The name of the label to remove.

    result

    Reporting success with true or false to indicate whether the operation was successful or not.

  • Returns all accessible conversations of the current user. If no conversation is present, an empty array is returned.

    Declaration

    Swift

    func getConversations(completion: @escaping ([ConversationInfo]) -> Void)
  • Checks if the Unblu view is presented as a modal view and is visible or not.

    Note

    If it is visible when receiving didRequestHideUi, ‘dismissModalView’ should be used to hide the modal view.

    Declaration

    Swift

    func isModalViewVisible() -> Bool
  • Set to enable if the floating button should appear when a conversation is open and the UnbluView is gets hidden It is disabled per default.

    Declaration

    Swift

    func setEnabledFloatingActiveConversationIndicator(_ enabled: Bool)

    Parameters

    enabled

    true to display the floating button, otherwise false

  • Shows an existing Unblu view in a new modal window. This temporarily moves the view from the current hierarchy to a new global window. After closing the new window, the Unblu view will be moved back to its previous location. This function can also be used if the Unblu view is not added anywhere. This function should not be used if the unblu view is visible. In this case first remove the Unblu view from its current parent. NOTE: Ensure that if the Unblu view is displayed modally with this function to also call dismissModalView before attching the unblu view directly somewhere else.

    Default Implementation

    Shows an existing Unblu view in a new modal window. This temporarily moves the view from the current hierarchy to a new global window. After closing the new window, the Unblu view will be moved back to its previous location. This function can also be used if the Unblu view is not added anywhere. This function should not be used if the unblu view is visible. In this case first remove the Unblu view from its current parent. NOTE: Ensure that if the Unblu view is displayed modally with this function to also call dismissModalView before attching the unblu view directly somewhere else.

    Declaration

    Swift

    func presentingAsModalView(reason: UnbluUiRequestReason, with animation: UnbluPresentationAnimationStyle, shadowStyle: UnbluPresentationShadowStyle, _ anchor: CGRect?)

    Parameters

    reason

    The reason why the view is displayed modally. Typically this is either ‘UnbluUiRequestReason.floatingActiveConversationButtonPressed’ or ‘UnbluUiRequestReason.pipButtonRequest’

    animation

    Animation effect that will be used to open and close the window

    shadowStyle

    The style of shadow that the window has

    anchor

    This is optional. The frame to/from of which the window expands/collapses.

  • Hide the current modal window with the animation effect used to open NOTE: this should only be called after calling presentingAsModalView and before trying to attach the Unblu view somewhere else directly if needed because it puts Unblu in its old place in the window hierarchy

    Declaration

    Swift

    func dismissModalView()
  • Check if floating active conversation indicator can be displayed and show it if it’s not visible.

    Declaration

    Swift

    func showFloatingActiveConversationIndicator()
  • Set Unblu view mode to modal view mode, this means removing the navigation pointer (back to overview, etc.)

    Declaration

    Swift

    func setModalMode(enabled: Bool, _ completion: @escaping (Bool) -> Void)

    Parameters

    enabled

    true to remove the navigation pointer, otherwise false

  • The name for the icon image that will be displayed on an active conversation indicator button. The icon with this name must be included in the app’s resources, and it is recommended that the minimum size of the icon is 80x80 pixels and It is preferable to have a round icon. If this name is not set, the avatar of the current agent will be displayed instead.

    Declaration

    Swift

    var activeConversationIndicatorIconName: String? { get set }
  • Indicates whether indicators have a removal area or not.

    Declaration

    Swift

    var indicatorsHaveRemovalArea: Bool { get set }

Convenience methods

  • stop() Extension method

    Declaration

    Swift

    func stop()