目录

Developing the web-view Component

web-view is a container that directly integrates the web page content into the UI of your atomic service, so that users can browse a web page without leaving the atomic service, thereby providing seamless browsing experience for users.

Preparations

  1. Configure business domain names.

  2. Install the JavaScript SDK. For details, please refer to JavaScript SDK.

  3. For details about the corresponding API capabilities, please refer to web-view.

JavaScript SDK

How to Obtain

Integrate the JavaScript SDK to your project in NPM mode.

How to Install

Open the cmd window in the target path and run the following npm command to obtain the corresponding JavaScript file:

npm install @atomicservice/ascf-web-sdk

How to Use

ES6

import has from '@atomicservice/ascf-web-sdk';

has.ascfweb.getEnv((res) => {
  console.info('getEnv success', res);
});

umd

<script src="../dist/ascf-web-sdk.umd.js"></script>
<script>
  has.ascfweb.getEnv((res) => {
    console.info('getEnv success', res);
  });
</script>

A success message displayed in the command output indicates that the SDK has been successfully installed and you can use the web-view component.

Copy the ascf-web-sdk.umd.js file in the npm installation package to the static resource directory of the project, and change the value of script src in the preceding example to the corresponding path.

User-Agent

When web-view is used to access the server, ASCF/App ID is appended to the end of the User-Agent string. The server can use this identifier to check whether the page is loaded within ASCF.

Example:

Bidirectional Communication Between the ASCF Atomic Service and the HTML5 Page Embedded in web-view

Bidirectional communication description

Example: