com.innovaphone.includes (Includes API)

The includes API allows one app (consumer) to retrieve and embed functionality from another app (provider) into an iframe.

An Include Provider defines one or more entry points, that expose parts of its UI/functionality. A Consumer App can retrieve these entry points via the Includes API and embed them using iframes.

Provider

Two standard entry points are:

Normally, content is created through edit, and later on accessed through open.

An include provider must declare these entry points in its API model. For JavaScript service based apps, this declaration has to be made in config.json.

"com.innovaphone.includes": {
  "title": "nameOfIncludeApp",
  "info": {
    "editUrl": "url/to/the/entry/point.htm",
    "openUrl": "url/to/the/entry/point.htm"
  }
}

Consumer

To use Includes in a consumer app it must:

  1. Consume the "Includes API"
  2. Retrieve the providers model and URLs
  3. Construct an iframe with the corresponding source attribute


const includesApi = start.consumeApi("com.innovaphone.includes");
const includeModel = includesApi.model['nameOfIncludeApp'];

const baseUrl = includeModel.url
const editUrl = url.slice(0, url.lastIndexOf("/")) + "/" + includeModel.info.editUrl;

const iframe = new innovaphone.ui1.Node("iframe")
iframe.setAttribute("src", editUrl);

Optionally, query parameters can be appended to pass to the provider app. The provider can then read and use the parameters as needed.


  iframe.setAttribute("src", editUrl + "?name=" + name + "&scheme=dark")