@react-native-ohos/react-native-douyin-lib 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/.gitattributes +1 -0
  2. package/OAT.xml +47 -0
  3. package/README.OpenSource +11 -0
  4. package/README.md +13 -0
  5. package/harmony/douyin/.ohpmrc +13 -0
  6. package/harmony/douyin/BuildProfile.ets +17 -0
  7. package/harmony/douyin/build-profile.json5 +28 -0
  8. package/harmony/douyin/hvigorfile.ts +6 -0
  9. package/harmony/douyin/index.ets +26 -0
  10. package/harmony/douyin/obfuscation-rules.txt +23 -0
  11. package/harmony/douyin/oh-package.json5 +14 -0
  12. package/harmony/douyin/src/main/cpp/CMakeLists.txt +9 -0
  13. package/harmony/douyin/src/main/cpp/generated/DouYinNativeModule.cpp +19 -0
  14. package/harmony/douyin/src/main/cpp/generated/DouYinNativeModule.h +16 -0
  15. package/harmony/douyin/src/main/cpp/generated/DouYinPackage.h +76 -0
  16. package/harmony/douyin/src/main/ets/RNDouYinPackage.ets +31 -0
  17. package/harmony/douyin/src/main/ets/RNDouYinTurboModule.ets +127 -0
  18. package/harmony/douyin/src/main/ets/generated/components/ts.ts +5 -0
  19. package/harmony/douyin/src/main/ets/generated/index.ets +5 -0
  20. package/harmony/douyin/src/main/ets/generated/ts.ts +6 -0
  21. package/harmony/douyin/src/main/ets/generated/turboModules/DouYinNativeModule.ts +19 -0
  22. package/harmony/douyin/src/main/ets/generated/turboModules/ts.ts +5 -0
  23. package/harmony/douyin/src/main/module.json5 +11 -0
  24. package/harmony/douyin/src/main/resources/base/element/color.json +8 -0
  25. package/harmony/douyin/src/main/resources/base/element/string.json +16 -0
  26. package/harmony/douyin/src/main/resources/base/profile/backup_config.json +3 -0
  27. package/harmony/douyin/src/main/resources/base/profile/main_pages.json +5 -0
  28. package/harmony/douyin/src/main/resources/en_US/element/string.json +16 -0
  29. package/harmony/douyin/src/main/resources/zh_CN/element/string.json +16 -0
  30. package/harmony/douyin/ts.ets +8 -0
  31. package/harmony/douyin.har +0 -0
  32. package/index.d.ts +24 -0
  33. package/index.js +26 -0
  34. package/package.json +42 -0
  35. package/react-native-douyin-lib.podspec +27 -0
  36. package/src/NativeRNDouYin.ts +20 -0
  37. package/src/RNDouYin.ts +3 -0
package/.gitattributes ADDED
@@ -0,0 +1 @@
1
+ *.pbxproj -text
package/OAT.xml ADDED
@@ -0,0 +1,47 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <configuration>
3
+ <oatconfig>
4
+ <licensefile>LICENSE</licensefile>
5
+ <policylist>
6
+ <policy name="projectPolicy" desc="">
7
+ <policyitem type="license" name="MIT" path=".*" desc="license under the MIT" />
8
+ </policy>
9
+ <policy name="projectPolicy" desc="">
10
+ <policyitem type="compatibility" name="GPL-2.0+" path=".*" desc="Process that runs independently, invoked by the X process." />
11
+ <policyitem type="compatibility" name="Apache-2.0" path=".*" desc="不影响兼容性" />
12
+ <policyitem type="compatibility" name="BSDStyleLicense" path=".*" desc="不影响兼容性" />
13
+ <policyitem type="compatibility" name="MIT" path=".*" desc="不影响兼容性" />
14
+ <policyitem type="compatibility" name="GPLStyleLicense" path=".*" desc="不影响兼容性" />
15
+ </policy>
16
+ </policylist>
17
+ <filefilterlist>
18
+ <filefilter name="copyrightPolicyFilter" desc="Filters for compatibility,license header policies">
19
+ <filteritem type="filepath" name="harmony/douyin/hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不手动修改" />
20
+ <filteritem type="filepath" name="harmony/douyin/src/main/cpp/.*" desc="Codegen生成文件,不手动修改" />
21
+ <filteritem type="filepath" name="harmony/douyin/src/main/ets/generated/.*" desc="Codegen生成文件,不手动修改" />
22
+ <filteritem type="filename" name="*.json5" desc="hvigor配置文件,DevEco Studio自动生成,不手动修改" />
23
+ <filteritem type="filename" name="*/*.json5" desc="hvigor配置文件,DevEco Studio自动生成,不手动修改" />
24
+ <filteritem type="filename" name="*.test.tsx" desc="测试文件,不手动修改" />
25
+ <filteritem type="filename" name="*.test.ets" desc="测试文件,不手动修改" />
26
+ <filteritem type="filename" name="*.config.js" desc="工程配置文件,不手动修改" />
27
+ <filteritem type="filename" name="*.nvmrc" desc="工程配置文件,不手动修改" />
28
+ <filteritem type="filename" name=".prettierrc.js" desc="工程配置文件,不手动修改" />
29
+ <filteritem type="filename" name=".yarnrc" desc="工程配置文件,不手动修改" />
30
+ <filteritem type="filename" name="yarn.lock" desc="工程配置文件,不手动修改" />
31
+ <filteritem type="filename" name=".npmignore" desc="工程配置文件,不手动修改" />
32
+ <filteritem type="filename" name=".ohpmignore" desc="工程配置文件,不手动修改" />
33
+ <filteritem type="filename" name="LICENSE" desc="版权文件,不添加版权头" />
34
+ <filteritem type="filepath" name="src/*.js" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险" />
35
+ <filteritem type="filepath" name="src/*.ts" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险" />
36
+ <filteritem type="filepath" name="*.js" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险" />
37
+ <filteritem type="filepath" name="*.ts" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险" />
38
+ <filteritem type="filepath" name="index.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险" />
39
+ <filteritem type="filename" name=".npmrc" desc="配置文件,不修改版权头" />
40
+ </filefilter>
41
+
42
+ <filefilter name="binaryFileTypePolicyFilter" desc="Filters for copyright header policies">
43
+ <filteritem type="filepath" name="harmony/douyin.har" desc="项目打包文件" />
44
+ </filefilter>
45
+ </filefilterlist>
46
+ </oatconfig>
47
+ </configuration>
@@ -0,0 +1,11 @@
1
+ [
2
+ {
3
+ "Name": "react-native-douyin",
4
+ "License": "MIT License",
5
+ "License File": "https://github.com/wiseqingyang/react-native-douyin/blob/master/LICENSE",
6
+ "Version Number": "1.1.4",
7
+ "Owner" : "panjinling@huawei.com",
8
+ "Upstream URL": "https://github.com/wiseqingyang/react-native-douyin",
9
+ "Description": "Tool library for initialization, authorization and sharing of Tiktok sdk"
10
+ }
11
+ ]
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # @react-native-ohos/react-native-douyin-lib
2
+
3
+ This project is based on [react-native-douyin@1.1.4](https://github.com/wiseqingyang/react-native-douyin/tree/v1.1.4)
4
+
5
+ ## Documentation
6
+
7
+ - [中文](https://gitcode.com/OpenHarmony-RN/usage-docs/blob/master/zh-cn/react-native-douyin.md)
8
+
9
+ - [English](https://gitcode.com/OpenHarmony-RN/usage-docs/blob/master/en/react-native-douyin.md)
10
+
11
+ ## License
12
+
13
+ This library is licensed under [The MIT License (MIT)](https://github.com/wiseqingyang/react-native-douyin/blob/master/LICENSE)
@@ -0,0 +1,13 @@
1
+ publish_registry=https://ohpm.byted.org/repos/ohpm
2
+ registry=https://ohpm.byted.org/repos/ohpm/,http://artifact.bytedance.com/repository/byted-ohpm/
3
+ # 开启依赖名称校验,本地依赖名称与其对应的包名是否一致,若不一致会导致命令执行失败
4
+ enforce_dependency_key=true
5
+ # 是否开启默认的冲突处理机制
6
+ resolve_conflict=true
7
+ # 是否安装工程所有模块的依赖
8
+ install_all=true
9
+ # 启用跨进程锁,ohpm不支持在同一个工程下并行运行多个ohpm 命令,保证串行执行
10
+ enable_cross_process_lock=true
11
+ # 开启依赖扫描功能,在执行ohpm publish命令时,会检查三方依赖是否都声明在dependencies中
12
+ ensure_dependency_include=true
13
+ strict_ssl=false
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Use these variables when you tailor your ArkTS code. They must be of the const type.
3
+ */
4
+ export const HAR_VERSION = '1.2.0-rc.1';
5
+ export const BUILD_MODE_NAME = 'debug';
6
+ export const DEBUG = true;
7
+ export const TARGET_NAME = 'default';
8
+
9
+ /**
10
+ * BuildProfile Class is used only for compatibility purposes.
11
+ */
12
+ export default class BuildProfile {
13
+ static readonly HAR_VERSION = HAR_VERSION;
14
+ static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
15
+ static readonly DEBUG = DEBUG;
16
+ static readonly TARGET_NAME = TARGET_NAME;
17
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "apiType": "stageMode",
3
+ "buildOption": {
4
+ },
5
+ "buildOptionSet": [
6
+ {
7
+ "name": "release",
8
+ "arkOptions": {
9
+ "obfuscation": {
10
+ "ruleOptions": {
11
+ "enable": false,
12
+ "files": [
13
+ "./obfuscation-rules.txt"
14
+ ]
15
+ }
16
+ }
17
+ }
18
+ },
19
+ ],
20
+ "targets": [
21
+ {
22
+ "name": "default"
23
+ },
24
+ {
25
+ "name": "ohosTest",
26
+ }
27
+ ]
28
+ }
@@ -0,0 +1,6 @@
1
+ import { harTasks } from '@ohos/hvigor-ohos-plugin';
2
+
3
+ export default {
4
+ system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
6
+ }
@@ -0,0 +1,26 @@
1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright (C) 2024 Huawei Device Co., Ltd.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ import { RNDouYinPackage } from './src/main/ets/RNDouYinPackage';
25
+ export default RNDouYinPackage;
26
+ export * from "./ts";
@@ -0,0 +1,23 @@
1
+ # Define project specific obfuscation rules here.
2
+ # You can include the obfuscation configuration files in the current module's build-profile.json5.
3
+ #
4
+ # For more details, see
5
+ # https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
6
+
7
+ # Obfuscation options:
8
+ # -disable-obfuscation: disable all obfuscations
9
+ # -enable-property-obfuscation: obfuscate the property names
10
+ # -enable-toplevel-obfuscation: obfuscate the names in the global scope
11
+ # -compact: remove unnecessary blank spaces and all line feeds
12
+ # -remove-log: remove all console.* statements
13
+ # -print-namecache: print the name cache that contains the mapping from the old names to new names
14
+ # -apply-namecache: reuse the given cache file
15
+
16
+ # Keep options:
17
+ # -keep-property-name: specifies property names that you want to keep
18
+ # -keep-global-name: specifies names that you want to keep in the global scope
19
+
20
+ -enable-property-obfuscation
21
+ -enable-toplevel-obfuscation
22
+ -enable-filename-obfuscation
23
+ -enable-export-obfuscation
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "@react-native-ohos/react-native-douyin-lib",
3
+ "version": "1.2.0",
4
+ "description": "Keep the screen from going to sleep",
5
+ "main": "index.ets",
6
+ "author": "",
7
+ "license": "Apache-2.0",
8
+ "dependencies": {
9
+ "@rnoh/react-native-openharmony": "file:../libs/react_native_openharmony-5.0.0.490.har",
10
+ "@douyin/opensdk-common-external": "0.0.5"
11
+ }
12
+ }
13
+
14
+
@@ -0,0 +1,9 @@
1
+ cmake_minimum_required(VERSION 3.13)
2
+ set(CMAKE_VERBOSE_MAKEFILE on)
3
+
4
+ set(rnoh_douyin_generated_dir "${CMAKE_CURRENT_SOURCE_DIR}/generated")
5
+ file(GLOB_RECURSE rnoh_douyin_generated_SRC "${rnoh_douyin_generated_dir}/*.cpp")
6
+ file(GLOB rnoh_douyin_SRC CONFIGURE_DEPENDS *.cpp)
7
+ add_library(rnoh_douyin SHARED ${rnoh_douyin_SRC} ${rnoh_douyin_generated_SRC})
8
+ target_include_directories(rnoh_douyin PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${rnoh_douyin_generated_dir})
9
+ target_link_libraries(rnoh_douyin PUBLIC rnoh)
@@ -0,0 +1,19 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ #include "DouYinNativeModule.h"
6
+
7
+ namespace rnoh {
8
+ using namespace facebook;
9
+
10
+ DouYinNativeModule::DouYinNativeModule(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name) {
11
+ methodMap_ = {
12
+ ARK_METHOD_METADATA(init, 1),
13
+ ARK_ASYNC_METHOD_METADATA(auth, 3),
14
+ ARK_ASYNC_METHOD_METADATA(shareVideo, 1),
15
+ ARK_METHOD_METADATA(isAppInstalled, 0),
16
+ };
17
+ }
18
+
19
+ } // namespace rnoh
@@ -0,0 +1,16 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ #pragma once
6
+
7
+ #include "RNOH/ArkTSTurboModule.h"
8
+
9
+ namespace rnoh {
10
+
11
+ class JSI_EXPORT DouYinNativeModule : public ArkTSTurboModule {
12
+ public:
13
+ DouYinNativeModule(const ArkTSTurboModule::Context ctx, const std::string name);
14
+ };
15
+
16
+ } // namespace rnoh
@@ -0,0 +1,76 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-harmony"
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be
5
+ * lost once the code is regenerated.
6
+ *
7
+ * @generatorVersion: 1
8
+ */
9
+
10
+ #pragma once
11
+
12
+ #include "RNOH/Package.h"
13
+ #include "RNOH/ArkTSTurboModule.h"
14
+ #include "DouYinNativeModule.h"
15
+
16
+ namespace rnoh {
17
+
18
+ class DouYinPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
19
+ public:
20
+ SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
21
+ if (name == "DouYinModule") {
22
+ return std::make_shared<DouYinNativeModule>(ctx, name);
23
+ }
24
+ return nullptr;
25
+ };
26
+ };
27
+
28
+ class DouYinPackageEventEmitRequestHandler : public EventEmitRequestHandler {
29
+ public:
30
+ void handleEvent(Context const &ctx) override {
31
+ auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
32
+ auto componentName = ctx.shadowViewRegistry->getComponentName(ctx.tag);
33
+
34
+ if (eventEmitter == nullptr) {
35
+ return;
36
+ }
37
+
38
+ std::vector<std::string> supportedComponentNames = {
39
+ };
40
+
41
+ std::vector<std::string> supportedEventNames = {
42
+ };
43
+
44
+ if (std::find(supportedComponentNames.begin(), supportedComponentNames.end(), componentName) != supportedComponentNames.end() &&
45
+ std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
46
+ eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
47
+ }
48
+ }
49
+ };
50
+
51
+ class DouYinPackage : public Package {
52
+ public:
53
+ DouYinPackage(Package::Context ctx) : Package(ctx){};
54
+
55
+ std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
56
+ return std::make_unique<DouYinPackageTurboModuleFactoryDelegate>();
57
+ }
58
+
59
+ std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
60
+ return {
61
+ };
62
+ }
63
+
64
+ ComponentJSIBinderByString createComponentJSIBinderByName() override {
65
+ return {
66
+ };
67
+ };
68
+
69
+ EventEmitRequestHandlers createEventEmitRequestHandlers() override {
70
+ return {
71
+ std::make_shared<DouYinPackageEventEmitRequestHandler>(),
72
+ };
73
+ }
74
+ };
75
+
76
+ } // namespace rnoh
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+
8
+ import { TurboModulesFactory } from '@rnoh/react-native-openharmony/ts';
9
+ import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
10
+ import { TM } from './generated/ts'
11
+ import { RNDouYinTurboModule } from './RNDouYinTurboModule';
12
+ import { RNOHPackage } from '@rnoh/react-native-openharmony';
13
+
14
+ class RNDouYinTurboModuleFactory extends TurboModulesFactory {
15
+ createTurboModule(name: string): TurboModule | null {
16
+ if (this.hasTurboModule(name)) {
17
+ return new RNDouYinTurboModule(this.ctx);
18
+ }
19
+ return null;
20
+ }
21
+
22
+ hasTurboModule(name: string): boolean {
23
+ return name === TM.DouYinNativeModule.NAME;
24
+ }
25
+ }
26
+
27
+ export class RNDouYinPackage extends RNOHPackage {
28
+ createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
29
+ return new RNDouYinTurboModuleFactory(ctx);
30
+ }
31
+ }
@@ -0,0 +1,127 @@
1
+ /*
2
+ * Copyright (c) 2026 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import { TurboModule, UITurboModuleContext } from '@rnoh/react-native-openharmony/ts';
8
+ import { TM } from './generated/ts';
9
+ import {
10
+ DouYinOpenConfigBuilder,
11
+ DouYinOpenListener,
12
+ douYinOpenSDK,
13
+ MixObject,
14
+ OpenAuthRequest,
15
+ OpenAuthResponse,
16
+ OpenShareRequest,
17
+ OpenShareResponse,
18
+ OpenTitleObject,
19
+ SupportApiName
20
+ } from '@douyin/opensdk-common-external';
21
+ import { bundleManager, common, Want } from '@kit.AbilityKit';
22
+ import { fileUri } from '@kit.CoreFileKit';
23
+
24
+ interface ShareConfig {
25
+ videos: string[];
26
+ isPublish?: boolean;
27
+ title?: string;
28
+ shortTitle?: string;
29
+ }
30
+
31
+ export class RNDouYinTurboModule extends TurboModule implements TM.DouYinNativeModule.Spec {
32
+ private appLink: string = '';
33
+
34
+ constructor(ctx: UITurboModuleContext) {
35
+ super(ctx);
36
+ }
37
+
38
+ init(appKey: string): void {
39
+ let apiParam = new DouYinOpenConfigBuilder(appKey)
40
+ .setDebug(true)
41
+ .build();
42
+ douYinOpenSDK.init(apiParam)
43
+ }
44
+
45
+ auth(scope: string, state: string, appLink: string): Promise<ESObject> {
46
+ this.appLink = appLink;
47
+ return new Promise((resolve, reject) => {
48
+ let listener: DouYinOpenListener = {
49
+ onSuccess: (response: OpenAuthResponse, authCode: string, grantedPermissions: string) => {
50
+ let result: ESObject = { code: response.isSuccess() ? 0 : response.errorCode, msg: response.errorMsg }
51
+ resolve(JSON.stringify(result))
52
+ },
53
+ onError: (response: OpenAuthResponse, errCode: number, errMsg: string) => {
54
+ let result: ESObject = { code: errCode, msg: errMsg }
55
+ reject(JSON.stringify(result));
56
+ }
57
+ }
58
+ let authRequest: OpenAuthRequest = new OpenAuthRequest();
59
+ authRequest.scope = scope;
60
+ authRequest.state = state;
61
+ authRequest.callerLocalEntry = "EntryAbility"
62
+ authRequest.redirectUri = appLink
63
+ douYinOpenSDK.createDouYinOpenApi()?.authorize(getContext() as common.UIAbilityContext, authRequest, listener)
64
+ });
65
+ }
66
+
67
+ shareVideo(shareConfig: ShareConfig): Promise<ESObject> {
68
+ return new Promise((resolve, reject) => {
69
+ let listener: DouYinOpenListener = {
70
+ onSuccess: (response: OpenShareResponse) => {
71
+ let result: ESObject = { code: response.isSuccess() ? 0 : response.errorCode, msg: response.errorMsg }
72
+ resolve(JSON.stringify(result))
73
+ },
74
+ onError: (response: OpenShareResponse, errCode: number, errMsg: string) => {
75
+ let result: ESObject = { code: errCode, msg: errMsg }
76
+ reject(JSON.stringify(result));
77
+ }
78
+ }
79
+ const request: OpenShareRequest = this.buildShareRequest(shareConfig.title, shareConfig.shortTitle)
80
+ let douYinOpenApi = douYinOpenSDK.createDouYinOpenApi()
81
+ if (douYinOpenApi?.isSupportApi(SupportApiName.SUPPORT_MIX) == true) {
82
+ let mixObject = new MixObject()
83
+ let videos = shareConfig.videos
84
+ if (videos && videos.length > 0) {
85
+ for (let i = 0; i < videos.length; i++) {
86
+ let uri = fileUri.getUriFromPath(videos[i])
87
+ mixObject.uriList.push(uri)
88
+ }
89
+ }
90
+ request.mediaObject = mixObject
91
+ }
92
+ douYinOpenSDK.createDouYinOpenApi()?.share(getContext() as common.UIAbilityContext, request, listener)
93
+ });
94
+ }
95
+
96
+ isAppInstalled(): boolean {
97
+ try {
98
+ let link = 'snssdk1128://aweme/detail';
99
+ let canOpen = bundleManager.canOpenLink(link);
100
+ return canOpen;
101
+ } catch (err) {
102
+ let message = (err as BusinessError).message;
103
+ console.info('canOpenLink failed:'+JSON.stringify(message))
104
+ return false;
105
+ }
106
+ }
107
+
108
+ private buildShareRequest(title: string | undefined, shortTitle: string | undefined): OpenShareRequest {
109
+ let request = new OpenShareRequest()
110
+ request.state = "state"
111
+ request.callerLocalEntry = "EntryAbility"
112
+ request.redirectUri = this.appLink
113
+ request.titleObject = new OpenTitleObject()
114
+ if (title) {
115
+ request.titleObject.title = title
116
+ }
117
+
118
+ if (shortTitle) {
119
+ request.titleObject.shortTitle = shortTitle
120
+ }
121
+ return request
122
+ }
123
+ }
124
+
125
+ export function doResult(context: common.UIAbilityContext, want: Want) {
126
+ douYinOpenSDK.doResult(context, want)
127
+ }
@@ -0,0 +1,5 @@
1
+
2
+ /**
3
+ */
4
+
5
+ export {}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ export * from "./ts"
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ export * as RNC from "./components/ts"
6
+ export * as TM from "./turboModules/ts"
@@ -0,0 +1,19 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ import { Tag } from "@rnoh/react-native-openharmony/ts"
6
+
7
+ export namespace DouYinNativeModule {
8
+ export const NAME = 'DouYinModule' as const
9
+
10
+ export interface Spec {
11
+ init(appKey: string): void;
12
+
13
+ auth(scope: string, state: string, appLink: string): Promise<any>;
14
+
15
+ shareVideo(shareConfig: any): Promise<any>;
16
+
17
+ isAppInstalled(): boolean;
18
+ }
19
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ export * from "./DouYinNativeModule"
@@ -0,0 +1,11 @@
1
+ {
2
+ "module": {
3
+ "name": "douyin",
4
+ "type": "har",
5
+ "deviceTypes": [
6
+ "default",
7
+ "tablet",
8
+ "2in1"
9
+ ]
10
+ },
11
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "color": [
3
+ {
4
+ "name": "start_window_background",
5
+ "value": "#FFFFFF"
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "module_desc",
5
+ "value": "module description"
6
+ },
7
+ {
8
+ "name": "send_intent_desc",
9
+ "value": "description"
10
+ },
11
+ {
12
+ "name": "send_intent_label",
13
+ "value": "label"
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "allowToBackupRestore": true
3
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "src": [
3
+ "pages/Index"
4
+ ]
5
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "module_desc",
5
+ "value": "module description"
6
+ },
7
+ {
8
+ "name": "send_intent_desc",
9
+ "value": "description"
10
+ },
11
+ {
12
+ "name": "send_intent_label",
13
+ "value": "label"
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "module_desc",
5
+ "value": "模块描述"
6
+ },
7
+ {
8
+ "name": "send_intent_desc",
9
+ "value": "description"
10
+ },
11
+ {
12
+ "name": "send_intent_label",
13
+ "value": "label"
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ export * from './src/main/ets/RNDouYinPackage';
8
+ export * from './src/main/ets/RNDouYinTurboModule'
Binary file
package/index.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ /*
2
+ * @Author: 唉诺
3
+ * @Date: 2021-04-30 23:31:46
4
+ */
5
+ declare module "react-native-douyin-lib" {
6
+ export interface IApiResponse {
7
+ code: number;
8
+ msg: string;
9
+ data: any;
10
+ }
11
+
12
+ export function init(appKey: string):Promise<void>;
13
+
14
+ export function auth(scope: string,state:string,appLink:string): Promise<any>;
15
+
16
+ export function shareVideo(shareConfig: {
17
+ videos: string[];
18
+ isPublish?: boolean;
19
+ title?: string;
20
+ shortTitle?: string;
21
+ }): Promise<any>;
22
+
23
+ export function isAppInstalled(): Promise<IApiResponse>;
24
+ }
package/index.js ADDED
@@ -0,0 +1,26 @@
1
+ import { NativeModules } from "react-native";
2
+
3
+ const { DouYinModule } = NativeModules;
4
+
5
+ export default Douyin = {
6
+ init(appKey) {
7
+ DouYinModule.init(appKey);
8
+ },
9
+
10
+ auth(scope, state, appLink) {
11
+ return DouYinModule.auth(scope, state, appLink);
12
+ },
13
+
14
+ shareVideo(config) {
15
+ return DouYinModule.shareVideo({
16
+ title: "",
17
+ shortTitle: "",
18
+ isPublish: false,
19
+ ...config,
20
+ });
21
+ },
22
+
23
+ isAppInstalled() {
24
+ return DouYinModule.isAppInstalled();
25
+ },
26
+ };
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@react-native-ohos/react-native-douyin-lib",
3
+ "title": "React Native Douyin",
4
+ "version": "1.2.0",
5
+ "description": "抖音登录、分享",
6
+ "main": "src/RNDouYin.ts",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/wiseqingyang/react-native-douyin.git",
13
+ "baseUrl": "https://github.com/wiseqingyang/react-native-douyin"
14
+ },
15
+ "keywords": [
16
+ "react-native"
17
+ ],
18
+ "author": {
19
+ "name": "wiseqingyang",
20
+ "email": "wiseqingyang@163.com"
21
+ },
22
+ "license": "MIT",
23
+ "licenseFilename": "LICENSE",
24
+ "readmeFilename": "README.md",
25
+ "peerDependencies": {
26
+ "react": "^16.8.1",
27
+ "react-native": ">=0.59.0-rc.0 <1.0.x"
28
+ },
29
+ "devDependencies": {
30
+ "react": "^16.8.3",
31
+ "react-native": "^0.59.10"
32
+ },
33
+ "harmony": {
34
+ "alias": "react-native-douyin-lib",
35
+ "autolinking": {
36
+ "etsPackageClassName":"RNDouYinPackage",
37
+ "cppPackageClassName":"DouYinPackage",
38
+ "cmakeLibraryTargetName": "rnoh_douyin",
39
+ "ohPackageName": "@react-native-ohos/react-native-douyin-lib"
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,27 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "react-native-douyin-lib"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.description = <<-DESC
10
+ react-native-douyin-lib
11
+ DESC
12
+ s.homepage = "https://github.com/wiseqingyang/react-native-douyin"
13
+ s.license = "MIT"
14
+ # s.license = { :type => "MIT", :file => "FILE_LICENSE" }
15
+ s.authors = { "Your Name" => "yourname@email.com" }
16
+ s.platforms = { :ios => "9.0", :tvos => "10.0" }
17
+ s.source = { :git => "https://github.com/wiseqingyang/react-native-douyin.git", :tag => "#{s.version}" }
18
+
19
+ s.source_files = "ios/**/*.{h,m,swift}"
20
+ s.requires_arc = true
21
+
22
+ s.dependency "React"
23
+ s.dependency "DouyinOpenSDK"
24
+
25
+ # s.dependency "..."
26
+ end
27
+
@@ -0,0 +1,20 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface Spec extends TurboModule {
5
+ init(appKey: string): void;
6
+
7
+ auth(scope: string,state:string,appLink:string): Promise<any>;
8
+
9
+ shareVideo(shareConfig: {
10
+ videos: string[];
11
+ isPublish?: boolean;
12
+ title?: string;
13
+ shortTitle?: string;
14
+ }): Promise<any>;
15
+
16
+ isAppInstalled(): boolean;
17
+
18
+ }
19
+
20
+ export default TurboModuleRegistry.getEnforcing<Spec>("DouYinModule");
@@ -0,0 +1,3 @@
1
+ import NativeRNDouYin from "./NativeRNDouYin";
2
+ const DouYin = NativeRNDouYin;
3
+ export default DouYin;