interface IUiAPI {
    get: ((code: string) => unknown);
    has: ((code: string) => boolean);
    hide: ((componentCode: string) => Promise<void>);
    register: ((code: string, init: ((api: IPublicAPI, config: unknown, onDrawnCallback: ((component: unknown) => void)) => unknown)) => void);
    registerAfter: ((dependencies: string[], code: string, init: ((api: unknown, config: unknown, onDrawnCallback: ((component: unknown) => void)) => unknown)) => void);
    show: ((componentCode: string, force: boolean) => Promise<void>);
    showPublicIdentifiers: (() => void);
    waitUntilDrawn: ((componentCode: string) => Promise<unknown>);
}

Properties

get: ((code: string) => unknown)

Returns a registered component The component may not be fully ready.

has: ((code: string) => boolean)

Returns whether a component exists for the specified code

hide: ((componentCode: string) => Promise<void>)

Hide a UI component once it is ready. For bundled components, this requires them to have been configured in batchSDK.setup()

register: ((code: string, init: ((api: IPublicAPI, config: unknown, onDrawnCallback: ((component: unknown) => void)) => unknown)) => void)

Register a new component for the specified code.

Type declaration

    • (code, init): void
    • Parameters

      • code: string

        Unique code for your UI component.

      • init: ((api: IPublicAPI, config: unknown, onDrawnCallback: ((component: unknown) => void)) => unknown)

        Init method of your component: Batch will call you back on it.

          • (api, config, onDrawnCallback): unknown
          • Parameters

            • api: IPublicAPI
            • config: unknown
            • onDrawnCallback: ((component: unknown) => void)
                • (component): void
                • Parameters

                  • component: unknown

                  Returns void

            Returns unknown

      Returns void

registerAfter: ((dependencies: string[], code: string, init: ((api: unknown, config: unknown, onDrawnCallback: ((component: unknown) => void)) => unknown)) => void)

Register a new component for the specified code, after waiting for other components to have been registered

Type declaration

    • (dependencies, code, init): void
    • Parameters

      • dependencies: string[]

        Components to wait for before calling this one's init method.

      • code: string

        Unique code for your UI component.

      • init: ((api: unknown, config: unknown, onDrawnCallback: ((component: unknown) => void)) => unknown)

        Init method of your component: Batch will call you back on it.

          • (api, config, onDrawnCallback): unknown
          • Parameters

            • api: unknown
            • config: unknown
            • onDrawnCallback: ((component: unknown) => void)
                • (component): void
                • Parameters

                  • component: unknown

                  Returns void

            Returns unknown

      Returns void

show: ((componentCode: string, force: boolean) => Promise<void>)

Show a UI component once it is ready. For bundled components, this requires them to have been configured in batchSDK.setup()

Some components will refuse to show even when calling this method because it might not make sense. For example, the banner will not honor the request if it has been dismissed recently (unless configured otherwise) or if the user is already subscribed to notifications.

You can try to set the force parameter to true, asking it to display itself no matter what.

If you call this method, you probably want to set "autoShow": false in your UI component configuration

showPublicIdentifiers: (() => void)

Shows the current user's identifiers inside the current page

waitUntilDrawn: ((componentCode: string) => Promise<unknown>)

Returns a promise that is resolved when the specified UI component has been drawn, returning the wrapped component.