目录

Atomic Service Adaptation Guide for HarmonyOS 4 and Earlier Versions

Currently, the adaptation is in the OBT phase. If you have any questions, please contact us via atomicservice@huawei.com.

To expand the user base of your atomic services and bring more traffic to you, we plan to use Quick App Center as the container to extend atomic services developed using ASCF to HarmonyOS 4 and earlier versions.

Powered by Quick App Center, ASCF atomic services can be developed, filed, and released once with a single codebase, supporting full coverage of all Huawei HarmonyOS devices.

The overall development and release process is the same as that for HarmonyOS 5.0 or later.

Due to differences in the OS and rendering environment, adaptation is still required in some scenarios for atomic services running on HarmonyOS 4 and earlier versions. You can identify the runtime environment using the methods below:

  1. In the atomic service, use the has.canIUse API or has.getSystemInfo().SDKVersion to check the runtime environment.
  2. For HTML pages inside the atomic service, identify the runtime environment via the User-Agent string.
    • Example User-Agent for HarmonyOS 5.0 or later: Mozilla/5.0 (Phone;OpenHarmony 5.1) AppleWebKit/537.36(KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 ArkWeb/4.1.6.1 Mobile ASCF/${appid}
    • Example User-Agent for HarmonyOS 4 or earlier: Mozilla/5.0 (Linux;; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/114.0.5735.196 Mobile Safari/537.36 ASCF/${appid} ASCFC/1.0.2.100**
    • appid stands for the app ID of your atomic service. You can use ASCF/${appid} to determine whether the current scenario is an atomic service scenario, and use OpenHarmony to distinguish the specific OS runtime environment.

Running and Debugging an Atomic Service

[h2]Running an Atomic Service by Scanning a QR Code

  1. Applying for a QR code:

    Send an email to Huawei operations personnel to apply for a test QR code as required. After receiving your request, Huawei operations personnel will send the test QR code to you within one working day.

    • Email address: atomicservice@huawei.com

    • Email subject: [Test QR code]-[Atomic service name]-[App ID]. For details about how to query the app ID, see Viewing App Basic Information.

    • Email body: Describe the QR code application requirement in the email body.

  2. Using the QR code:

    • Open AppGallery, search for Quick App Center, and update the app to the latest version.

    • Open HUAWEI Assistant·TODAY on a Huawei phone, and touch the QR code scanning icon in the upper right corner to scan the QR code and directly access your atomic service.

[h2]Running an Atomic Service Using the Loader

[h2]Debugging and Running an Atomic Service Using ASCF Toolkit

Connect to a phone running HarmonyOS 4 or earlier, and use the ASCF CLI tool to develop and debug your atomic service. For details, please refer to ASCF Toolkit (CLI Tool).

Adaptation Guide

If your atomic service has been released for HarmonyOS 5.0 and later, and you want to distribute it to HarmonyOS 4 and earlier and perform testing, use either of the following approaches to run your atomic service.

[h2]Component/API Adaptation

The runtime environment of an atomic service on HarmonyOS 5.0 and later is similar to that on HarmonyOS 4 and earlier. That is, the JavaScript code at the logic layer runs on V8, and the view layer is rendered based on the native ArkWeb engine of HarmonyOS.

The runtime mechanism, update mechanism, component framework, and other capabilities remain the same. However, due to differences in the WebView kernel and system APIs across platforms, feature support varies in some cases, mostly related to components and APIs.

You can check via the has.canIUse API or has.getDeviceInfo().platform === 'ohos' and make necessary adjustments to your service logic for compatibility. List the features that are not currently supported and ensure compatibility when they are used. See the related documentation for full component/API support details.

Use has.getDeviceInfo().platform to determine the runtime platform. has.getDeviceInfo().platform === 'ohos' indicates that the runtime environment is HarmonyOS 5.0 or later. Otherwise, it is HarmonyOS 4 or earlier.

Container-Specific Differences

[h2]Supported Format

Deep link format:

hap://app/<package>/[path][?key=value]
Parameter Type Mandatory Description
package string Yes Atomic service package name.
path string No Path of a page in the atomic service. The default value is the home page path.
key-value string No Parameter to be passed to the page. Multiple key-value pairs are allowed. The passed parameter values may be obtained by other apps. Therefore, you are advised not to transfer data with high security sensitivity.

[h2]Key Component/API Differences

Components

Component HarmonyOS 5.0 and Later HarmonyOS 4 and Earlier Difference
input/text-area √ √ On HarmonyOS 4 and earlier versions, after the soft keyboard is triggered for the input and text-area components, if the keyboard is dismissed by tapping the upper-right corner of the keyboard, the input box retains focus.
camera √ √ On HarmonyOS 4 and earlier versions, the camera loading page is transparent.
map √ √ For the map component on HarmonyOS 4 and earlier, differences exist in the location icon style, marker icon style, default visibility of zoom icons, and label rendering on markers.
video √ √ HarmonyOS 4 and earlier versions do not support Media Controller.

Atomic services running on HarmonyOS 4 and earlier use stacked rendering. cover-view/cover-image is used to display text/image views that overlay native components. The native components that can be overlaid include map, video, canvas, and camera.

APIs

On HarmonyOS 4 and earlier, API behaviors differ from those on HarmonyOS 5.0 and later. For details, see the following table. For unsupported APIs, you need to temporarily hide related capabilities or adopt alternative solutions.

API HarmonyOS 5.0 and Later HarmonyOS 4 and Earlier Difference
has.requestContract √ × HarmonyOS 4 and earlier versions do not support this API.
has.createThirdPayClient √ × HarmonyOS 4 and earlier versions do not support this API.
ThirdPayClient.pay √ × HarmonyOS 4 and earlier versions do not support this API.
has.hideShareMenu √ × HarmonyOS 4 and earlier versions do not support this API.
has.showShareMenu √ × HarmonyOS 4 and earlier versions do not support this API.
has.startRealNameVerification √ × HarmonyOS 4 and earlier versions do not support this API.
has.startRealNameAuth √ × HarmonyOS 4 and earlier versions do not support this API.
has.startFaceVerification √ √ For HarmonyOS 4 and earlier versions, HUAWEI Wallet must be upgraded to 9.0.46 or later.
has.getAvatarInfo √ × HarmonyOS 4 and earlier versions do not support this API.
has.getInvoiceTitle √ × HarmonyOS 4 and earlier versions do not support this API.
has.getDeliveryAddress √ × HarmonyOS 4 and earlier versions do not support this API.
has.getServiceSubscription √ × HarmonyOS 4 and earlier versions do not support this API.
has.onLazyLoadError √ × HarmonyOS 4 and earlier versions do not support this API.
has.offLazyLoadError √ × HarmonyOS 4 and earlier versions do not support this API.
has.chooseAddress √ × HarmonyOS 4 and earlier versions do not support this API.
has.chooseInvoiceTitle √ × HarmonyOS 4 and earlier versions do not support this API.
has.getPushToken √ × HarmonyOS 4 and earlier versions do not support this API.
has.deletePushToken √ × HarmonyOS 4 and earlier versions do not support this API.
Service widget √ × HarmonyOS 4 and earlier versions do not support service widgets.
has.scanCode √ √ On HarmonyOS 4 and earlier versions, even if the input parameter onlyFromCamera is set to true, photos can still be selected from Gallery.
canvas √ √ On HarmonyOS 4 and earlier versions, the lines drawn on the canvas are relatively thick.
CanvasContext.measureText √ √ On HarmonyOS 4 and earlier versions, the return value of width is automatically rounded to an integer. On HarmonyOS 5.0 and later versions, the return value retains the decimal part.
CanvasContext.globalCompositeOperation √ √ On HarmonyOS 4 and earlier, drawing results for destination-atop, source-in, and destination-in differ.
CanvasContext.setStrokeStyle √ √ On HarmonyOS 4 and earlier versions, if you pass createLinearGradient(x0, y0, x1, y1) with invalid arguments to the color parameter, the behavior differs from that on HarmonyOS 5.0 and later.
has.onSocketError / SocketTask.onError √ √ The error codes returned by the has.onSocketError/SocketTask.onError API on HarmonyOS 4 and earlier are different from those on HarmonyOS 5.0 and later in exception scenarios. The error information is transparently transmitted by the underlying network framework layer.
has.request √ √ Due to differences in the underlying network framework, profile in successful responses is inconsistent between versions.
BackgroundAudioManager √ √ The Media Controller screen on HarmonyOS 4 and earlier is different. The progress bar, playback position, and total audio duration are not displayed, and the audio cover is shown on the right.
has.playBackgroundAudio √ √ When background audio is played on HarmonyOS 4 or earlier, the capability of controlling background playback is not available.
MapContext.toScreenLocation √ √ Due to the differences in the dependent map SDK across platforms, the precision of the screen coordinates corresponding to the longitude and latitude is inconsistent.

When certain system capabilities (such as network, map, and IAP) are called under some error conditions, the framework passes through the underlying errors to the atomic service, and error codes may differ between versions.

It is recommended that you perform adaptation based on user scenarios during development.

[h2]Applying for Release or Removal

After your atomic service is released on AppGallery, if you need to distribute it to devices running HarmonyOS 4 or earlier, you can send an email to apply for the distribution. Huawei operations personnel will provide the handling result within three working days.

Basic Information Description
Atomic service name Name of the atomic service on AppGallery.
APP ID Sign in to HUAWEI Developers, click Development and services, find the desired project, go to Project settings > General information, and obtain the app ID in the App information area.

After your atomic service is distributed to HarmonyOS 4 or earlier, if you release a new atomic service version on AppGallery, Huawei operations personnel will synchronize the version within one working day. No additional action is required from you.