Skip to main content

HarmonyOS integration

Packages and environment​

Headless HAR is @edukits/edusdk; UI Kit HAR is @edukits/edusdk-ui. The edukits spelling differs from Web's eduskit scope.

The examples/hms project uses DevEco Studio, HarmonyOS SDK 6.1.1 / API 24, OHPM and Hvigor with locally built 0.1.1 HAR dependencies.

Build and dependencies​

Run make harmony-napi from edu-sdks to generate the arm64 N-API module. Open examples/hms in DevEco, install its local HAR dependencies and build the HAP. UI Kit depends on Headless; the host does not directly load Rust/N-API on the UI thread.

Headless entry​

Supply backend HTTP, IM, RTC and whiteboard capabilities through hostEffectHandler:

import { EduSdk, EduSdkCreateOptions, EnterClassroomParams } from '@edukits/edusdk';

// hostEffectHandler is implemented by the host's HTTP and provider adapters.
const sdk = EduSdk.create(
new EduSdkCreateOptions(appId, backendUrl, accessToken, hostEffectHandler),
);
sdk.onClassInfoChanged((info) => {
/* render info */
});
await sdk.initialize();
sdk.enterClassroom(new EnterClassroomParams(classroomId, eduUserId, displayName));
// On exit:
sdk.leaveClassroom();
await sdk.destroy();

HostEffectHandler receives effectsJson. Execute the requested operations and return their results to the same Core through complete(resultJson).

Await both initialize() and destroy(). A destroyed instance cannot be reused. Wait for its Worker to finish destruction before creating a replacement.

Integration limitations​

The HAP example provides a portrait starter UI without complete provider bindings; missing bindings report unregistered capabilities. Complete N-API Worker, teaching-tool, sound and media integration on target devices before release.

getMemberActionPolicy(userId) returns asynchronously prepared actions. Update the UI when those results are ready and configure permissions, networking and lifecycle handling for the enabled features.