Updated on 2023-03-23 GMT+08:00

Scenario 1: Initialization

Description

The initialization API can be called for SDK initialization after a third-party application starts. You only need to call this API once. You must call this API before calling other functional APIs.

Service Process

During SDK initialization, if the Windows 64-bit platform is used, change the name of the HwmSdk.exe file in the HwmSdk folder and call the init synchronization API.

  1. Change the name of the .exe file (only for the Windows 64-bit platform).

    Change the name of the HwmSdk.exe file in the HwmSdk folder to MySdk.exe.

  2. Call an API.

    1. Construct the InitInfo data structure.
    2. Call the Init API to initialize the configuration. The data in the preceding step is used as input parameters.

Sample Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
/**
* Call the initialization API and start the application.
*/
async goToInit() {
    let param = {
        exePath: "E:\\Hello_World\\debug\\win32\\HwmSdk\\MySdk.exe",// Configure the SDK path only for the Windows 64-bit platform. Assume that the HwmSdk directory is in E:\\Hello_World\\debug\\win32\\ and the .exe file name is MySdk.exe. (The path must be encoded using UTF-8.)
        logPath: "E:\\Hello_World\\debug\\win32\\MySdk\\log\\",// Specify the log path. (The path must be encoded using UTF-8.)
        userDataPath: "E:\\Hello_World\\debug\\win32\\MySdk\\UserData\\", // Specify the data path. (The path must be encoded using UTF-8.)
        appId: "602b111272ad4b6989e683c27e6e87d4"
    };
    const apiService = new ApiService();
    let setResult = await apiService.init(param);
    if (setResult != 0) {
        window.electron.ipcRenderer.send("show-error-alert", "init error = " + setResult.ret);
    }
}
1
2
3
4
5
6
7
8
9
/**
* Definition of init in ApiService
*/
init(initInfo) {
  console.log("init, in param = ", initInfo);
  let ret = this.uisdkService.init(initInfo);
  console.log("init, out data = ", ret);
  return ret;
}

The sample code in the typical scenario and API reference is pseudo code and cannot be directly used.