#  HarmonyOS Adaptation Guide

This article will introduce how to use Feishu JSAPI in HarmonyOS for web applications, regular web pages, and Mini Programs.
<br>

## Precautions
- The old version of the three-stage client API will not be adapted to HarmonyOS due to security compliance reasons. If the old version of the three-stage client API is used in your application, please migrate to the new version of the one-stage client JSAPI as soon as possible. For details, see [Mapping of old and new version client APIs](https://open.larkoffice.com/document/uYjL24iN/uAjMuAjMuAjM/comparison-of-old-and-new-client-apis)

## 1. Web applications and regular web pages in Feishu Adaptation Instructions

## Step 1: Upgrade the SDK to the latest version
If you are directly referencing Feishu JSSDK and using version 1.5.35 or later, this step can be omitted, and you can use it directly on HarmonyOS without modification.

If the JSSDK you're referencing is located on your own server, not from Feishu's official CDN source; or if you're referencing Feishu's source but using a version earlier than 1.5.35; then you need to switch to referencing the latest JSSDK version provided by Feishu.  <br>
To get the JSSDK, go to [the latest SDK](https://open.feishu.cn/document/uYjL24iN/uMTMuMTMuMTM/introduction#24a7a6e3)

## Step 2: Check JSAPI compatibility

Test your system with Feishu (version 7.35 +) on HarmonyOS. If the API used is not supported, an error code 103 will be returned. The errString is "API not available". Feishu will support it as soon as possible in future versions.
In each API documentation, you can also find the current API support status.

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/2b15ee240bb3fe144d24c4fa6d314dd8_5uunb9o0MR.png?height=536&lazyload=true&width=2484)
Fully supported APIs have been marked with specific supported HarmonyOS versions.

## Step 3: Adapt Client Special Logic

Determine whether it is HarmonyOS through navigator.userAgent

```javascript 
const isHarmony = /OpenHarmony/i.test(navigator.userAgent)
``` 

## 2. Gadget Adaptation Instructions

## Step 1: Check JSAPI compatibility

Test your system with Feishu (version 7.35 +) on HarmonyOS. If the API used is not supported, an error code 103 will be returned. The errString is "API not available". Feishu will support it as soon as possible in future versions.
In each API documentation, you can also find the current API support status.

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/2b15ee240bb3fe144d24c4fa6d314dd8_5uunb9o0MR.png?height=536&lazyload=true&width=2484)
Fully supported APIs have been marked with specific supported HarmonyOS versions.

## Step 2: Adapt Client Special Logic

In Gadget, determine whether it is a HarmonyOS system by reading the platform in [getSystemInfo](https://open.feishu.cn/document/uYjL24iN/uQjNx4CN2EjL0YTM).

```javascript 
const systemInfo = tt.getSystemInfoSync();
const isHarmony = systemInfo.platform === 'openharmony';
``` 

## 3. Support

The following lists the APIs that are not currently supported. Compatibility must be ensured for the APIs that are not supported. For specific API support information, please jump to the corresponding document for details. Feishu will iterate the unsupported APIs in future versions as soon as possible. Please pay attention to the release of the latest client.

Module | API | Support
---|---|---
Open Ability-Chat | getBlockActionSourceDetail / getTriggerContext / onChatBadgeChange / offChatBadgeChange | Not supported.
Open Ability-Chat | chooseChat | Partially not supported, the following parameters are not supported:<br>- allowCreateGroup
Open Ability-Contact | chooseContact | Partially not supported, the following parameters are not supported:<br>- externalContact<br>- enableChooseDepartment<br>- showRelatedOrganizations
Open Ability-Share | share | Not supported.
Open Ability-AppBadge | updateBadge / onServerBadgePush / offServerBadgePush | Not supported.
Interface-Interaction Feedback | showToast / showLoading | Partially not supported, the following parameters are not supported:<br>- mask: Transparency mask is not effective
Interface-Customized Input | getCustomizedInput / CustomizedInput | Partially not supported, the following APIs are not supported:<br>- CustomizedInput.onPicSelect<br>- CustomizedInput.onModelSelect
Interface-Pad | togglePadFullScreen / getPadDisplayScaleMode | Not supported.
Interface-DarkMode | onThemeChange / offThemeChange | Not supported.
Device-Scan Code | scanCode | Partially not supported, the following parameters are not supported:<br>- barCodeInput
File | filePicker | Partially not supported: <br>Currently only system file selectors are supported, and the passed parameters have no effect.
File | openDocument | Partially not supported, the following parameters are not supported:<br>- fileType<br>- showMenu<br>Only supports PDF and cloud document preview.
Media-Image | getImageInfo | Partially not supported:<br>Only local images are supported.
Media-Video | chooseMedia | Partially not supported, the following parameters are not supported:<br>- maxDuration<br>- sizeType
Media-Audio | createInnerAudioContext / InnerAudioContext | Partially not supported, the following parameters are not supported:<br>- onWaiting<br>- offWaiting
Media-BackgroundAudio | getBackgroundAudioManager / BackgroundAudioManager | Not supported.
Media-Camera | createCameraContext / CameraErrno / CameraContext | Not supported.
Update | getUpdateManager / UpdateManager | Not supported.
Performance | getPerformanceRecorder / PerformanceRecorder | Not supported.

