Skip Navigation

IExternalCommunicationService

The IExternalCommunicationService currently includes one method that allows to properly open a new window (or tab) based on your environment. Optionally it allows for message posting and listening between windows (or tabs).

Acquiring IExternalCommunicationService

In order to obtain IExternalCommunicationService and use it, you need to import it, e.g.

import {IExternalCommunicationService} from "sabre-ngv-communication/interfaces/IExternalCommunicationService";

Then obtain the service inside your source as below:

const externalCommunicationService: IExternalCommunicationService = getService(IExternalCommunicationService);

Available methods

Currently available methods:

openWindow
abstract openWindow(URL: string, targetOrigin?: string, listener?: (event: MessageEvent) => void): ((data: JsonObject) => void | void);

Opens up new browser window (or tab) and optionally allows for message posting and listening between windows (or tabs).

Type Parameteres:

  • URL - URL of website that we want to open

Optional Type Parameteres:

  • targetOrigin - Origin of URL we want to open

  • listener - Method that will be executed when external website sends us message

Returns:
If additional parameters have been passed method returns a function that posts messages to external website, otherwise it returns void.

You can see service usage in com.sabre.redapp.example3.web.crosswindow sample.