Acrobits IPC SDK
    Preparing search index...

    Class IPCManager

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

    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.

    Index

    Constructors

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

      Parameters

      • Optionallogger: ILogger

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

      Returns IPCManager

      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.

    host?: HostType

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

    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.

    • Initiates the IPC handshake with the Host app.

      Returns Promise<void>

    • Matches batch of ContactItem objects against the Host's contact list to fetch detailed contact information.

      Parameters

      Returns Promise<
          | Record<string, undefined | null | DetailedContactItem>
          | CloudUsernameDetailedContactItem[],
      >

      A collection of DetailedContactItem objects which were matched against the Host's contact list.

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

      Parameters

      • callback: (event: string, payload: Record<string, unknown>) => void

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

      Returns UnsubscribeCallback

      An unsubscribe callback to remove the listener.

      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: string, appId: string, selector: string) => void

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

      Returns () => undefined | boolean

      An unsubscribe callback to remove the listener.

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

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

      Parameters

      • callback: (skipCompression?: boolean) => void

        A callback function to be invoked when a IPCEvents.RequestLogs event is received. The callback receives an optional skipCompression parameter.

      Returns () => undefined | boolean

      An unsubscribe callback to remove the listener.

      The Host app can request logs from the Client app by sending a RequestLogs event. The callback will receive a skipCompression parameter indicating whether the logs should be compressed or not.

      When skipCompression is true, the logs should be sent uncompressed. When false or undefined, the logs should be compressed before sending.

    • 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

      • Optionaldata: TData

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

      Returns void

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

      // import the IPCManager
      import { IPCManager } from '@acrobits/ipc-sdk';

      // create an instance of IPCManager
      const manager = new IPCManager();

      // open the URL with additional data
      const url = 'https://example.com';
      const data = {
      name: 'John Doe',
      age: 30
      };

      manager.openUrl(url, data);
    • Requests the Host app to reset the app and log out the user.

      Returns void

      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

      • options: SelectContactsOptions

        Configuration options for contact selection:

        • mode: Whether to allow 'single' or 'multi' contact selection
        • currentContacts: For multi-select mode, the list of currently selected contacts
        • contactType: The type of contacts to select ('cloudUsername' or 'uri'). Defaults to 'cloudUsername'
        • includeOffNetworkContacts: Whether to include contacts not on the network. Defaults to false

      Returns Promise<ContactItem[]>

      A collection of ContactItem objects which the user selected

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

      Parameters

      • corelationId: number

        An identifier for the message stream

      • Optionalmode: "single"

        Optional. Whether to allow single or multi contact selection.

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

      Use the selectContacts method with the options parameter instead.

      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.

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

      Use the selectContacts method with the options parameter instead.

      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.