UnbluCoreApi

@objc
open class UnbluCoreApi : NSObject
extension UnbluCoreApi: UnbluNotificationApiDelegate

The API to use to access unblu suite functionality like showing, opening conversations

Before calling any other function #configureApi should be called inside the AppDelegate.

Use the constants of UnbluEventApi to register for events and access their user info data

A typical flow for the usage would be:

AppDelegate#application() {
   UnbluCoreApi.instance.configureApi(UnbluApiConfiguration(unbluBaseUrl: "<base-url>", apiKey: "<apiKey>"))

   //register for general errors and/or also other events
   NotificationCenter.default.addObserver(self, selector: #selector(AppDelegate.handleErrorEvent(notification:)), name: Notification.Name.UnbluError, object: nil)

   //start the api. This could also be done later when it is needed, but it will take a while until the api is ready
   UnbluCoreApi.instance.initApi(success: {<success handling>}, failure: {<error handling>})
}
SomeViewController#showConversations() {
   //the conversations should be shown
   UnbluCoreApi.instance.showUi(visible: true)
}
  • 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

    public static var enableDebugOutput: Bool
  • 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 debug via logLevel!

    Declaration

    Swift

    public static var enableCapturingPerformanceLogging: Bool
  • Defines the log level of the Unblu SDK. All messages with a lower level will not be logged.

    Default value is LogLevel.info

    Declaration

    Swift

    public static var logLevel: LogLevel
  • Prevents the scrolling of the ui when the keyboard is shown/hidden

    This setting should only be changed, if it does create issues. If it is disabled, the user of the sdk has to take care that the ui container/the webview inside is correctly resize if needed

    Declaration

    Swift

    public static var preventScrollingByKeyboard: Bool
  • The time used for the fade in and fade out animation when showing/hiding the ui

    Declaration

    Swift

    public static let ANIMATION_TIME: TimeInterval
  • As the Unblu SDK defines an own UIWindow with a UIViewController, iOS uses this controller to define the StatusBarStyle. There is no proper way of checking for the real active UIViewController from which this value should be taken. Therefor it is required to also set the correct StatusBarStyle for the UIViewController inside the SDK.

    Declaration

    Swift

    @objc
    public dynamic var preferredStatusBarStyle: UIStatusBarStyle
  • Custom loading view creator which is used whenever a loading view is displayed

    Declaration

    Swift

    public var customLoadingViewCreator: UnbluCustomLoadingViewCreator?
  • This is for internal purpose only!

    Declaration

    Swift

    public let delegate: CoreApiDelegate
  • The configuration for the main UnbluUIWindow (i.e. the UIWindow that contains displayable content like the WebView).

    Declaration

    Swift

    public var uiWindowConfiguration: UnbluUIWindowConfiguration? { get }
  • The configuration for the hidden UnbluUIWindow.

    Declaration

    Swift

    public var hiddenUiWindowConfiguration: UnbluHiddenUIWindowConfiguration? { get }
  • Internal access to the controller of the unblu UI

    Declaration

    Swift

    public private(set) var uiController: UnbluUiController? { get }
  • Internal driver. Needed to access driver from Visitor/Agent SDK

    Declaration

    Swift

    public private(set) var driver: MobileDeviceDriverCoreApi? { get }
  • The currently configured bottom margin of the UI

    Declaration

    Swift

    public private(set) var uiBottomMargin: CGFloat { get }
  • The currently configured top margin of the UI

    Declaration

    Swift

    public private(set) var uiTopMargin: CGFloat { get }
  • The instance of the UnbluCoreApi. This getter is for internal use only. Use the one from the agent/visitor api

    Declaration

    Swift

    public private(set) static var internalInstance: UnbluCoreApi? { get }
  • Internal constructor. Used by Agent/Visitor SDK

    Declaration

    Swift

    public init(_ delegate: CoreApiDelegate,
                unbluNotificationApi: UnbluNotificationApi = .instance,
                systemEventsCoordinator: SystemEventsCoordinator = NotificationCenter.default)

Public

  • Number of unread messages

    Declaration

    Swift

    var unreadMessagesCount: Int { get }
  • Configures the unblu api. Use #initializeApi() 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.

      • configuration: The configuration for the unblu api

      Throws

      Throws an error if the api was already initialized. The api needs to be deinitialized to configure it.

    Declaration

    Swift

    func configureApi(configuration: UnbluApiConfiguration) throws

    Parameters

    configuration

    The configuration for the unblu api

  • Inits the unblu API.

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

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

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

    Declaration

    Swift

    func initApi(success: (() -> Void)? = nil, preloadUiFinished: (() -> Void)? = nil, failure: ((UnbluApiInitializeError) -> Void)? = nil)

    Parameters

    success

    Optional callback that will be called once the API has been successfully initialized.

    preloadUiFinished

    Optional callback that will be called once the ui is preloaded. (Preloading must be enabled)

    failure

    Optional callback that will be called if the initialization of the API fails.

  • 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 inbetween) will be ignored, but the callbacks will also be triggered, as soon as there is a result.

    Declaration

    Swift

    func deinitApi(success: (() -> Void)? = nil, failure: ((UnbluApiDeinitializeError) -> Void)? = nil)

    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.

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

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

    Declaration

    Swift

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

    Parameters

    success

    Callback that will be called with true if the API is initialized. false otherwise.

  • Returns true if the API is in error state.

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

    Declaration

    Swift

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

    Parameters

    success

    Callback that will be called with true if the API is in error state. false otherwise.

  • Starts preloading the ui. Can be called as soon as the api is initialized. It will load the page, which is needed later for the ui. If enablePreloadUiAfterApiInit of #configureApi is set to true.

    Calling this function multiple times will have no effect.

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

    Declaration

    Swift

    func preloadUi(success: (() -> Void)? = nil, failure: ((UnbluApiNotInitializedError) -> Void)? = nil)

    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.

  • When called, the given UnbluCookie objects are passed to the Unblu WebView, and used in future network requests made by this WebView. This function can be called independent of the state of the api. If the api was already initialized, calling this function will overwrite any existing cookies in the WebView with the same key, all other previously set cookies will not be changed. All cookies will be removed when #deinitApi is called. When #initApi is called again, only the last Set of cookies passed to this function will be used.

    Declaration

    Swift

    func setCustomCookies(_ customCookies: Set<UnbluCookie>)

    Parameters

    customCookies

    A Set of UnbluCookie objects which will be sent with requests to the configured base url

  • 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).

    Declaration

    Swift

    func setNamedArea(_ namedArea: String?)

    Parameters

    namedArea

    The named area meta tag id which is configured on the agent desk.

  • Checks if the call UI for an audio/video call is open or not. If the call Ui is minized, the result is also false. If you need to check if a call is active or not. Use the #isCallActive function.

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

    Declaration

    Swift

    func isCallUiOpen(success: ((Bool) -> Void)? = nil, failure: ((UnbluApiNotInitializedError) -> Void)? = nil)

    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.

  • Checks if the ui is visible or not

    Declaration

    Swift

    func isUiVisible(_ callback: @escaping (Bool) -> Void)

    Parameters

    callback

    Triggered with the result if the ui is visible or not

  • Displays are hides the unblu ui

    Declaration

    Swift

    func showUi(visible: Bool, animate: Bool = true, success: (() -> Void)? = nil, failure: ((UnbluApiNotInitializedError) -> Void)? = nil)

    Parameters

    visible

    If set to true, the ui will be display. If set to false, it will be hidden

    animate

    If set to true, displaying/hidding the ui will be animated

    success

    Called after the ui is displayed/hidden and (if enabled) the animation has finished

    failure

    Called if the api was not initialized first

  • Set the margins of the UI. This can be used, if there should be a an open/close fab button or some menu at the top

    Declaration

    Swift

    func setUiMargins(top uiTopMargin: CGFloat, bottom uiBottomMargin: CGFloat, animate: Bool = false)

    Parameters

    top

    The amount of margin in pixel at the top

    bottom

    The amount of margin in pixel at the bottom

    animate

    If set to true, the change of the margin is animated. Default is false

  • 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 (wait for the success callback).

    Declaration

    Swift

    func openConversation(_ conversationId: String, success: (() -> Void)? = nil, failure: ((UnbluApiOpenConversationError) -> Void)? = nil)

    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

  • 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 (wait for the success callback).

    Declaration

    Swift

    func startAudioCall(_ conversationId: String, success: (() -> Void)? = nil, failure: ((UnbluApiStartAudioCallError) -> Void)? = nil)

    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

  • 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 (wait for the success callback).

    Declaration

    Swift

    func startVideoCall(_ conversationId: String, success: (() -> Void)? = nil, failure: ((UnbluApiStartVideoCallError) -> Void)? = nil)

    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

  • Opens the overview over all conversations. The unblu UI must have been visible at least once. You can call this after a call to showUi (wait for the success callback).

    Declaration

    Swift

    func openConversationOverview(success: (() -> Void)? = nil, failure: ((UnbluApiOpenConversationOverviewError) -> Void)? = nil)

    Parameters

    success

    Called when the overview was opened

    failure

    Called if there was an error opening the overview

  • Returns the id of the currently opened conversation inside the UI. Null if no conversation is open

    Declaration

    Swift

    func getOpenConversationId(success: @escaping (String?) -> Void, failure: ((UnbluApiRetrieveOpenConversationIdError) -> Void)? = nil)

    Parameters

    success

    Called with the currently open conversation id or nil

    failure

    Called if the api is not initialized or the UI was never shown

  • Returns the info of the current person

    Declaration

    Swift

    func getPersonInfo(success: @escaping (PersonInfo) -> Void, failure: ((UnbluApiRetrievePersonInfoError) -> Void)? = nil)

    Parameters

    success

    Called with the current person information

    failure

    Called if the api is not initialized or the used collaboration server is not of version 5.x newer than 5.17 or newer than 6.3

  • Helper to quickly check if is initialized. Should only be called inside an main.async queue

    Declaration

    Swift

    func isInitializedInternal() -> Bool
  • Returns a module based on the given type

    Declaration

    Swift

    func getModule<T>(_ type: T.Type) -> T? where T : IAbstractBaseModule