Skip to content

Commit 901ba62

Browse files
authored
Merge pull request #114 from yeliulee/ohos_flutter_3.22
add support for HarmonyOS and implementation for QRCode Auth
2 parents b493831 + c2da4ce commit 901ba62

Some content is hidden

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

50 files changed

+1062
-8
lines changed

.metadata

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ migration:
2121
- platform: ios
2222
create_revision: 9cd3d0d9ff05768afa249e036acc66e8abe93bff
2323
base_revision: 9cd3d0d9ff05768afa249e036acc66e8abe93bff
24+
- platform: ohos
25+
create_revision: 9cd3d0d9ff05768afa249e036acc66e8abe93bff
26+
base_revision: 9cd3d0d9ff05768afa249e036acc66e8abe93bff
2427

2528
# User provided section
2629

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 6.1.0
2+
3+
* 新增: 对 `HarmonyOS` 的支持, 受限于 SDK, 仅支持部分功能
4+
* 新增: Server-Side Code 模式登录
5+
* 新增: 二维码授权登录
6+
17
## 6.0.1
28

39
* iOS: 优化 ruby 脚本

README.md

+42-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Flutter 版腾讯(QQ)SDK
2929

3030
### Android
3131

32-
```
32+
```txt
3333
# 不需要做任何额外接入工作
3434
# 配置已集成到脚本里
3535
# 混淆已打入 Library,随 Library 引用,自动添加到 apk 打包混淆
@@ -39,7 +39,7 @@ Flutter 版腾讯(QQ)SDK
3939

4040
> 暂不支持 SceneDelegate,详见文档 [iOS_SDK环境搭建](https://wiki.connect.qq.com/ios_sdk%e7%8e%af%e5%a2%83%e6%90%ad%e5%bb%ba)
4141
42-
```
42+
```txt
4343
# 不需要做任何额外接入工作
4444
# 配置已集成到脚本里
4545
```
@@ -70,6 +70,44 @@ https://${your applinks domain}/universal_link/${example_app}/qq_conn/${appId}
7070

7171
> ⚠️ 很多 SDK 都会用到 universal_link,可为不同 SDK 分配不同的 path 以作区分
7272
73+
### HarmonyOS
74+
75+
> 当前在 `HarmonyOS` 平台, 仅支持 `setIsPermissionGranted/registerApp/isQQInstalled/loginServerSide`
76+
>
77+
> 由于 SDK 限制,当前仅支持 Server-Side 模式登录,auth code 在 accessToken 字段,获取后可自行在后端使用
78+
79+
项目中 module.json5 的 "module" 节点下配置 querySchemes
80+
81+
```json5
82+
"querySchemes": [
83+
"https",
84+
"qqopenapi"
85+
]
86+
```
87+
88+
在 Ability 的 skills 节点中配置 scheme
89+
90+
```json5
91+
"skills": [
92+
{
93+
"entities": [
94+
"entity.system.browsable"
95+
],
96+
"actions": [
97+
"ohos.want.action.viewData"
98+
],
99+
"uris": [
100+
{
101+
"scheme": "qqopenapi", // 接收 QQ 回调数据
102+
"host": "102061317", // 业务申请的互联 appId
103+
"path": "auth",
104+
"linkFeature": "Login",
105+
}
106+
]
107+
}
108+
]
109+
```
110+
73111
### Flutter
74112

75113
|分享类型|说说(图/文/视频)|文本|图片|音乐|视频|网页|
@@ -84,7 +122,8 @@ https://${your applinks domain}/universal_link/${example_app}/qq_conn/${appId}
84122
* 兼容
85123

86124
flutter 2.5 兼容问题 [issues/54](https://github.com/RxReader/tencent_kit/issues/54)
87-
```
125+
126+
```ruby
88127
post_install do |installer|
89128
installer.pods_project.targets.each do |target|
90129
flutter_additional_ios_build_settings(target)
-342 KB
Binary file not shown.
Binary file not shown.

android/src/main/java/io/github/v7lin/tencent_kit/TencentKitPlugin.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,18 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
181181

182182
private void login(@NonNull MethodCall call, @NonNull Result result) {
183183
final String scope = call.argument("scope");
184+
final boolean qrcode = call.argument("qrcode");
184185
if (tencent != null) {
185-
tencent.login(activityPluginBinding.getActivity(), scope, loginListener);
186+
tencent.login(activityPluginBinding.getActivity(), scope, loginListener, qrcode);
186187
}
187188
result.success(null);
188189
}
189190

190191
private void loginServerSide(@NonNull MethodCall call, @NonNull Result result) {
191192
final String scope = call.argument("scope");
193+
final boolean qrcode = call.argument("qrcode");
192194
if (tencent != null) {
193-
tencent.loginServerSide(activityPluginBinding.getActivity(), scope, loginListener);
195+
tencent.loginServerSide(activityPluginBinding.getActivity(), scope, loginListener, qrcode);
194196
}
195197
result.success(null);
196198
}

example/ohos/.gitignore

+19
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

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"app": {
3+
"bundleName": "io.github.v7lin.tencent_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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"string": [
3+
{
4+
"name": "app_name",
5+
"value": "tencent_kit_example"
6+
}
7+
]
8+
}
Loading

example/ohos/build-profile.json5

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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: "tencent_kit",
43+
srcPath: "../../ohos",
44+
targets: [
45+
{
46+
name: "default",
47+
applyToProducts: ["default"],
48+
},
49+
],
50+
},
51+
]
52+
}

example/ohos/entry/.gitignore

+7
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
+29
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

+17
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

+27
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+
"tencent_kit": "../../../ohos"
25+
},
26+
}
27+
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+
}
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+
}

0 commit comments

Comments
 (0)