To mitigate cross-platform compatibility inconsistencies and enable efficient migration and development in the mini-program ecosystem, ASCF implements an enhanced version management policy. As the ASCF runtime capabilities continue to evolve, some APIs may behave differently across versions. You are advised to implement proper compatibility handling during integration. Existing features in older versions remain stable. New versions provide enhanced capabilities and optimizations while retaining backward compatibility.
You can follow the approaches described below for compatibility handling.
To address the feature differences between earlier and later runtime versions, you can set a minimum required runtime version.
Open the oh-package.json5 file in the entry directory of your project.
Open the command terminal in the root directory of the project and run the following command to update dependencies:
ohpm i

After setting the minimum runtime version, you need to adapt to differences in some APIs. For example, for the has.chooseMedia API, the duration property returned is measured in milliseconds in ASCF runtime versions earlier than 2.0.1, and in seconds for version 2.0.1 and later.
has.chooseMedia({
count: 1,
mediaType: ['video'],
sourceType: ['album'],
success: (res) => {
// If the minimum runtime version is set to ^2.0.0, the duration of the selected video is measured in seconds.
const videoDuration = res.tempFiles[0].duration;
console.info('chooseMedia success, videoDuration:', videoDuration);
}
}); | Difference | Versions Earlier Than 2.0.1 | 2.0.1 and Later Versions | Impact Scope |
|---|---|---|---|
| Video duration: duration | Unit: millisecond | Unit: second | |
| Return value of MapContext.toScreenLocation | Unit: px | Unit: vp | MapContext.toScreenLocation |
| Custom request header: header | The data is parsed based on the first content-type value. | The data is parsed based on the last content-type value. | has.request |
| TLS encryption protocol | The TLS 1.2 encryption protocol is not supported. | The TLS 1.2 encryption protocol is supported. | has.request |
| Return value for listening for privacy statement change events | The value is a JSON string and needs to be deserialized. | The value is of the object type. | has.onPrivacyStateChanged |
| Safe area on the portrait screen: safeArea | The safe area includes the bottom navigation bar. If you need to calculate the height for avoiding the bottom navigation bar, use the indicatorHeight field. | The safe area does not include the bottom navigation bar. | |
| iconPath property of a marker | By default, the image is displayed in its original size. | By default, the image can be scaled based on the current screen density. | map component |
| Default padding style | The left and right padding values are 0. | If size is set to mini, the left and right padding values are 8px. If size is set to default, the left and right padding values are 14px. | Button component (when open-type is set to getPhoneNumber, share, liveActivity) |