- android/setup.md: 新增 sdk-bugcollect、配置文件、BugCollect 章节 - ios/setup.md: 新增配置文件章节、setUserInfo - rn/setup.md: withXuqmConfig Metro 插件、@xuqm/rn-bugcollect - flutter/setup.md: 新增配置文件章节 - harmony/setup.md: 新增配置文件章节 - guide/quickstart.md: 更新配置文件获取流程 - guide/concepts.md: 新增 BugCollect 服务概念 - guide/flow.md: 更新服务流程 Co-Authored-By: Claude <noreply@anthropic.com>
115 行
1.9 KiB
Markdown
115 行
1.9 KiB
Markdown
# HarmonyOS 安装配置
|
||
|
||
**包名**:`@xuqm/harmony-sdk` · **版本**:0.1.0 · **语言**:ArkTS
|
||
|
||
---
|
||
|
||
## ohpm 安装
|
||
|
||
在 HarmonyOS 项目的 `oh-package.json5` 中添加:
|
||
|
||
```json5
|
||
{
|
||
"dependencies": {
|
||
"@xuqm/harmony-sdk": "^0.1.0"
|
||
}
|
||
}
|
||
```
|
||
|
||
然后执行:
|
||
|
||
```bash
|
||
ohpm install
|
||
```
|
||
|
||
> 发布仓库:`https://ohpm.openharmony.cn/ohpm/`
|
||
|
||
---
|
||
|
||
## 最低 API 版本
|
||
|
||
- API 12+(HarmonyOS 4.0+)
|
||
- DevEco Studio 4.0 Release 或更高版本
|
||
|
||
---
|
||
|
||
## 权限配置
|
||
|
||
在 `module.json5` 中声明所需权限:
|
||
|
||
```json5
|
||
{
|
||
"module": {
|
||
"requestPermissions": [
|
||
{
|
||
"name": "ohos.permission.INTERNET"
|
||
},
|
||
{
|
||
"name": "ohos.permission.GET_NETWORK_INFO"
|
||
}
|
||
]
|
||
}
|
||
}
|
||
```
|
||
|
||
如需使用相机、相册、麦克风等功能,额外添加:
|
||
|
||
```json5
|
||
{
|
||
"module": {
|
||
"requestPermissions": [
|
||
{
|
||
"name": "ohos.permission.CAMERA"
|
||
},
|
||
{
|
||
"name": "ohos.permission.READ_MEDIA"
|
||
},
|
||
{
|
||
"name": "ohos.permission.WRITE_MEDIA"
|
||
},
|
||
{
|
||
"name": "ohos.permission.MICROPHONE"
|
||
}
|
||
]
|
||
}
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
## 配置文件
|
||
|
||
从平台控制台下载应用的 `.xuqmconfig` 配置文件(例如 `识校宝.xuqmconfig`),放置到 `src/main/resources/rawfile/config/` 目录,随 HAP 一起打包。SDK 启动时会自动扫描该目录并读取配置,无需手动指定路径。
|
||
|
||
文件名不限,只要扩展名为 `.xuqmconfig` 即可。
|
||
|
||
---
|
||
|
||
## 初始化
|
||
|
||
```ts
|
||
import { XuqmSDK } from '@xuqm/harmony-sdk'
|
||
import common from '@ohos.app.ability.common'
|
||
|
||
// 在 EntryAbility.onCreate 或页面初始化时
|
||
const context = getContext(this) as common.UIAbilityContext
|
||
await XuqmSDK.init(context, {
|
||
appKey: 'your_app_key',
|
||
})
|
||
```
|
||
|
||
---
|
||
|
||
## 登录
|
||
|
||
```ts
|
||
const session = await XuqmSDK.login('user_001', 'your_user_sig_jwt')
|
||
```
|
||
|
||
---
|
||
|
||
## 下一步
|
||
|
||
- [HarmonyOS IM 接入 →](./im)
|
||
- [HarmonyOS 授权管理 →](./license)
|