Skip to content

Commit a37c68a

Browse files
authored
Add impl for WeChat on HarmonyOS (#153)
Signed-off-by: yeliulee <yeliuleet@gmail.com>
1 parent ecdec65 commit a37c68a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1129
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 6.1.0
2+
3+
* 新增对 OpenHarmony 的支持
4+
15
## 6.0.2
26

37
* 配置 Android 命名空间

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,22 @@ https://${your applinks domain}/universal_link/${example_app}/wechat/
106106

107107
> ⚠️ 很多 SDK 都会用到 universal_link,可为不同 SDK 分配不同的 path 以作区分
108108
109+
### OpenHarmony / HarmonyOS
110+
111+
> 当前 OpenHarmony 的微信 SDK 仅支持部分 API, 使用过程中请自行查阅文档
112+
113+
为了检查是否安装了微信,请在项目的 module.json5 文件中添加以下 scheme
114+
115+
```json5
116+
{
117+
"module": {
118+
"querySchemes": [
119+
"weixin"
120+
],
121+
}
122+
}
123+
```
124+
109125
### Flutter
110126

111127
* 配置

example/ohos/.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/node_modules
2+
/oh_modules
3+
/local.properties
4+
/.idea
5+
**/build
6+
/.hvigor
7+
.cxx
8+
/.clangd
9+
/.clang-format
10+
/.clang-tidy
11+
**/.test
12+
*.har
13+
**/BuildProfile.ets
14+
**/oh-package-lock.json5
15+
16+
**/src/main/resources/rawfile/flutter_assets/
17+
**/libs/arm64-v8a/libapp.so
18+
**/libs/arm64-v8a/libflutter.so
19+
**/libs/arm64-v8a/libvmservice_snapshot.so

example/ohos/AppScope/app.json5

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"app": {
3+
"bundleName": "io.github.v7lin.wechat_kit_example",
4+
"vendor": "example",
5+
"versionCode": 1000000,
6+
"versionName": "1.0.0",
7+
"icon": "$media:app_icon",
8+
"label": "$string:app_name"
9+
}
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"string": [
3+
{
4+
"name": "app_name",
5+
"value": "wechat_kit_example"
6+
}
7+
]
8+
}
Loading

example/ohos/build-profile.json5

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
{
17+
"app": {
18+
"signingConfigs": [],
19+
"products": [
20+
{
21+
"name": "default",
22+
"signingConfig": "default",
23+
"compatibleSdkVersion": "5.0.0(12)",
24+
"runtimeOS": "HarmonyOS",
25+
}
26+
]
27+
},
28+
"modules": [
29+
{
30+
"name": "entry",
31+
"srcPath": "./entry",
32+
"targets": [
33+
{
34+
"name": "default",
35+
"applyToProducts": [
36+
"default"
37+
]
38+
}
39+
]
40+
},
41+
{
42+
"name": "wechat_kit",
43+
"srcPath": "../../ohos",
44+
"targets": [
45+
{
46+
"name": "default",
47+
"applyToProducts": [
48+
"default"
49+
]
50+
}
51+
]
52+
}
53+
]
54+
}

example/ohos/entry/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
/node_modules
3+
/oh_modules
4+
/.preview
5+
/build
6+
/.cxx
7+
/.test
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
{
17+
"apiType": 'stageMode',
18+
"buildOption": {
19+
},
20+
"targets": [
21+
{
22+
"name": "default",
23+
"runtimeOS": "HarmonyOS"
24+
},
25+
{
26+
"name": "ohosTest",
27+
}
28+
]
29+
}

example/ohos/entry/hvigorfile.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
17+
export { hapTasks } from '@ohos/hvigor-ohos-plugin';

example/ohos/entry/oh-package.json5

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
{
17+
"name": "entry",
18+
"version": "1.0.0",
19+
"description": "Please describe the basic information.",
20+
"main": "",
21+
"author": "",
22+
"license": "",
23+
"dependencies": {
24+
"wechat_kit": "file:../../../ohos"
25+
},
26+
}
27+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
import { FlutterAbility, FlutterEngine } from '@ohos/flutter_ohos';
17+
import { GeneratedPluginRegistrant } from '../plugins/GeneratedPluginRegistrant';
18+
19+
export default class EntryAbility extends FlutterAbility {
20+
configureFlutterEngine(flutterEngine: FlutterEngine) {
21+
super.configureFlutterEngine(flutterEngine)
22+
GeneratedPluginRegistrant.registerWith(flutterEngine)
23+
}
24+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
import common from '@ohos.app.ability.common';
17+
import { FlutterPage } from '@ohos/flutter_ohos'
18+
19+
let storage = LocalStorage.getShared()
20+
const EVENT_BACK_PRESS = 'EVENT_BACK_PRESS'
21+
22+
@Entry(storage)
23+
@Component
24+
struct Index {
25+
private context = getContext(this) as common.UIAbilityContext
26+
@LocalStorageLink('viewId') viewId: string = "";
27+
28+
build() {
29+
Column() {
30+
FlutterPage({ viewId: this.viewId })
31+
}
32+
}
33+
34+
onBackPress(): boolean {
35+
this.context.eventHub.emit(EVENT_BACK_PRESS)
36+
return true
37+
}
38+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
{
16+
"module": {
17+
"name": "entry",
18+
"type": "entry",
19+
"description": "$string:module_desc",
20+
"mainElement": "EntryAbility",
21+
"deviceTypes": [
22+
"phone"
23+
],
24+
"deliveryWithInstall": true,
25+
"installationFree": false,
26+
"pages": "$profile:main_pages",
27+
"abilities": [
28+
{
29+
"name": "EntryAbility",
30+
"srcEntry": "./ets/entryability/EntryAbility.ets",
31+
"description": "$string:EntryAbility_desc",
32+
"icon": "$media:icon",
33+
"label": "$string:EntryAbility_label",
34+
"startWindowIcon": "$media:icon",
35+
"startWindowBackground": "$color:start_window_background",
36+
"exported": true,
37+
"skills": [
38+
{
39+
"entities": [
40+
"entity.system.home"
41+
],
42+
"actions": [
43+
"action.system.home"
44+
]
45+
}
46+
]
47+
}
48+
],
49+
"requestPermissions": [
50+
{"name" : "ohos.permission.INTERNET"},
51+
]
52+
}
53+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"color": [
3+
{
4+
"name": "start_window_background",
5+
"value": "#FFFFFF"
6+
}
7+
]
8+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"string": [
3+
{
4+
"name": "module_desc",
5+
"value": "module description"
6+
},
7+
{
8+
"name": "EntryAbility_desc",
9+
"value": "description"
10+
},
11+
{
12+
"name": "EntryAbility_label",
13+
"value": "wechat_kit_example"
14+
}
15+
]
16+
}
Loading
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"string": [
3+
{
4+
"name": "enable_impeller",
5+
"value": "true"
6+
}
7+
]
8+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"src": [
3+
"pages/Index"
4+
]
5+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"string": [
3+
{
4+
"name": "module_desc",
5+
"value": "module description"
6+
},
7+
{
8+
"name": "EntryAbility_desc",
9+
"value": "description"
10+
},
11+
{
12+
"name": "EntryAbility_label",
13+
"value": "wechat_kit_example"
14+
}
15+
]
16+
}

0 commit comments

Comments
 (0)