A class that manages the IPC communication between the Client and the Host.

Remarks

Ideally, there should only be one instance of the IPCManager in the app. It is recommended to create the instance as a singleton and use it throughout the app.

Constructors

  • A class that manages the IPC communication between the Client and the Host.

    Parameters

    • Optional logger: ILogger

      An optional logger instance to use for logging. If not provided, a default logger will be used.

    Returns IPCManager

    Remarks

    Ideally, there should only be one instance of the IPCManager in the app. It is recommended to create the instance as a singleton and use it throughout the app.

Properties

cloudId?: string

The cloud ID of the Host app the Client is embedded in.

cloudUsername?: string

The cloud username of the logged in user.

displayName?: string

The display name of the logged in user.

helper: IpcHelper
host?: HostType

The type of the Host app the Client is embedded in.

listeners: Map<IPCEvents, Set<GenericCallback>>
logger: ILogger

Accessors

  • get context(): undefined | "host" | "standalone"
  • Returns whether the app is running inside a native WebView (host context) or as a standalone app.

    Returns undefined | "host" | "standalone"

  • get isConnected(): boolean
  • Determines if the app is connected to a Host app.

    Returns boolean

Methods

  • Sends the current badge count to the Host app.

    Parameters

    • count: number

      The count to update the badge to.

    • isActivity: boolean = false

      Optional. Whether the update is for an activity instead of a badge.

    Returns void

  • Determines if the app is embedded in a Host app or native CSP clients.

    Returns Promise<undefined | "host" | "standalone">

    A promise with IPCContext the app is running under.

  • Parameters

    • Optional context: AppContext

    Returns undefined | "host" | "standalone"

  • Initiates the IPC handshake with the Host app.

    Returns Promise<void>

  • Registers a callback to be invoked when a IPCEvents.Lifecycle event is received.

    Parameters

    • callback: ((event, payload) => void)

      A callback function to be invoked when a IPCEvents.Lifecycle event is received.

        • (event, payload): void
        • Parameters

          • event: string
          • payload: Record<string, unknown>

          Returns void

    Returns UnsubscribeCallback

    An unsubscribe callback to remove the listener.

    Remarks

    The eventName and payload are defined by the Host app and can vary for each LIFECYCLE event. The payload can be an empty object for events without any additional data.

  • Registers a callback to be invoked when a IPCEvents.PushToken event is received.

    Parameters

    • callback: ((token, appId, selector) => void)

      A callback function to be invoked when a IPCEvents.PushToken event is received.

        • (token, appId, selector): void
        • Parameters

          • token: string
          • appId: string
          • selector: string

          Returns void

    Returns (() => undefined | boolean)

    An unsubscribe callback to remove the listener.

      • (): undefined | boolean
      • Returns undefined | boolean

    Remarks

    The token, appId, selector and expiry are defined by the Host app and can vary for each Push Token event.

  • Requests the Host app to open the given URL in an external browser.

    Type Parameters

    • TData

    Parameters

    • url: string

      URL to open in the external browser

    • Optional data: TData

      Optional. Any additional data to be sent along with the URL

    Returns void

    Remarks

    Any additional data to be posted alongside the URL is included with the data parameter.

  • Requests the Host app to reset the app and log out the user.

    Returns void

    Remarks

    For added security, the Host can confirm the user's intention to reset the app by displaying a confirmation dialog. The user can decide to cancel the reset operation.

  • Requests the Host app to provide the Push Token for the current device.

    Returns Promise<string>

    A promise with the Push Token as string.

  • Requests the Host app to open the contact selection UI.

    Parameters

    • corelationId: number

      An identifier for the message stream

    • Optional mode: "single"

      Optional. Whether to allow single or multi contact selection.

    • Optional contactType: ContactType

      Optional. The type of contacts to be selected. This can be either cloudUsername or uri. Defaults to cloudUsername.

    Returns Promise<ContactItem[]>

    A collection of ContactItem objects which the user selected along with the corelationId.

    Remarks

    When requesting a single contact, the Host app will return immediately after contact selection.

  • Requests the Host app to open the contact selection UI.

    Parameters

    • corelationId: number

      An identifier for the message stream

    • mode: "multi"

      Whether to allow single or multi contact selection.

    • currentContacts: ContactItem[]

      A list of ContactItem objects that are currently selected. This is used to highlight the current contacts from the selection UI.

    • Optional contactType: ContactType

      Optional. The type of contacts to be selected. This can be either cloudUsername or uri. Defaults to cloudUsername.

    Returns Promise<ContactItem[]>

    A collection of ContactItem objects which the user selected along with the corelationId.

    Remarks

    When requesting a multi contact, the user will have to manually close the contact selection UI. The Host app will return the selected contacts when the user closes the UI.

    When requesting a multi contact, the currentContacts parameter is required. This will be used to highlight the contacts that are already selected.

  • Initiates a SIP call to the given ContactItem.

    Parameters

    Returns void

Generated using TypeDoc