From 6ad5a6fe2795638cd020b1febab13abfb6bfce17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=BF=97=E9=B9=8F?= Date: Thu, 7 Nov 2024 20:49:30 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20[Issues:=20#IB2TKY]=E4=BF=AE=E6=94=B9re?= =?UTF-8?q?act-native-wechat-lib=E4=BD=BF=E7=94=A8=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- en/react-native-wechat-lib.md | 41 +++++++++++++++++++++++++------- zh-cn/react-native-wechat-lib.md | 41 +++++++++++++++++++++++++------- 2 files changed, 64 insertions(+), 18 deletions(-) diff --git a/en/react-native-wechat-lib.md b/en/react-native-wechat-lib.md index 59582712..ae9451ad 100644 --- a/en/react-native-wechat-lib.md +++ b/en/react-native-wechat-lib.md @@ -213,7 +213,29 @@ export default class EntryAbility extends RNAbility { ``` -### 4. Configuring CMakeLists and Introducing BaseReactNativeWechatLibPackage +### 4. Configuring module.json5 + +open `entry/src/main/module.json5` and add the following code: + +```diff +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default" + ], ++ "querySchemes": [ ++ "weixin", ++ ], + ... + } +} +``` + +### 5. Configuring CMakeLists and Introducing RNWechatLibPackage open `entry/src/main/cpp/CMakeLists.txt` and add the following code: @@ -259,7 +281,7 @@ Open `entry/src/main/cpp/PackageProvider.cpp` and add the following code: #include "RNOH/PackageProvider.h" #include "generated/RNOHGeneratedPackage.h" #include "SamplePackage.h" -+ #include "BaseReactNativeWechatLibPackage.h" ++ #include "RNWechatLibPackage.h" using namespace rnoh; @@ -267,12 +289,12 @@ std::vector> PackageProvider::getPackages(Package::Cont return { std::make_shared(ctx), std::make_shared(ctx), -+ std::make_shared(ctx), ++ std::make_shared(ctx), }; } ``` -### 5. Introducing WechatLibPackage to ArkTS +### 6. Introducing WechatLibPackage to ArkTS Open the `entry/src/main/ets/RNPackagesFactory.ts` file and add the following code: @@ -288,7 +310,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 6. Running +### 7. Running Click the `sync` button in the upper right corner. @@ -315,10 +337,12 @@ Check the release version information in the release address of the third-party > [!tip] If the value of **HarmonyOS Support** is **yes**, it means that the HarmonyOS platform supports this property; **no** means the opposite; **partially** means some capabilities of this property are supported. The usage method is the same on different platforms and the effect is the same as that of iOS or Android. +> [!TIP] The rules for mobile applications to jump to Mini Program, [please refer to the feature introduction for launching Mini Program in the app](https://developers.weixin.qq.com/doc/oplatform/Mobile_App/Launching_a_Mini_Program/Launching_a_Mini_Program.html) + | Name | Description | Type | Required | Platform | HarmonyOS Support | | --------------------------------------------- | ------------------ | -------- | -------- | ----------- | ----------------- | | registerApp(appid) | register | Function | no | Android/iOS | yes | -| isWXAppInstalled() | Determine whether WeChat is installed | Function | no | Android/iOS | no | +| isWXAppInstalled() | Determine whether WeChat is installed | Function | no | Android/iOS | yes | | isWXAppSupportApi() | Check support | Function | no | Android/iOS | no | | getApiVersion() | Get API version number | Function | no | Android/iOS | no | | openWXApp() | Open WeChat | Function | no | Android/iOS | yes | @@ -332,7 +356,7 @@ Check the release version information in the release address of the third-party | shareVideo(ShareVideoMetadata) | Share Video | Function | no | Android/iOS | no | | shareWebpage (ShareWebpageMetadata) | Share Webpage | Function | no | Android/iOS | no | | shareMiniProgram(ShareMiniProgramMetadata) | Share MiniProgram | Function | no | Android/iOS | no | -| launchMiniProgram (LaunchMiniProgramMetadata) | Launch MiniProgram | Function | no | Android/iOS | no | +| launchMiniProgram (LaunchMiniProgramMetadata) | Launch MiniProgram | Function | no | Android/iOS | yes | | chooseInvoice (ChooseInvoice) | Select invoice | Function | no | Android/iOS | no | | pay(payload) | pay | Function | no | Android/iOS | yes | | subscribeMessage(SubscribeMessageMetadata) | @@ -343,8 +367,7 @@ One-time subscription to messages | Function | no | Android/iOS | no ## Others - ShareText、ShareImage、ShareLocalImage: Only sharing is supported, collection is not supported, because the WeChat Open SDK currently does not support collection on the HarmonyOS platform. -- isWXAppInstalled: The reason why it is not supported is that HarmonyOS does not support obtaining the application list data installed on the device. -- isWXAppSupportApi、getApiVersion、ShareFile、ShareMusic、ShareVideo、ShareWebpage 、ShareMiniProgram、LaunchMiniProgram、ChooseInvoice、subscribeMessage. These interfaces are currently not supported by HarmonyOS WeChat Open SDK. +- isWXAppSupportApi、getApiVersion、ShareFile、ShareMusic、ShareVideo、ShareWebpage 、ShareMiniProgram、ChooseInvoice、subscribeMessage. These interfaces are currently not supported by HarmonyOS WeChat Open SDK. ## License diff --git a/zh-cn/react-native-wechat-lib.md b/zh-cn/react-native-wechat-lib.md index d7437d08..6ead08f3 100644 --- a/zh-cn/react-native-wechat-lib.md +++ b/zh-cn/react-native-wechat-lib.md @@ -216,7 +216,29 @@ export default class EntryAbility extends RNAbility { ``` -### 4.配置 CMakeLists 和引入 BaseReactNativeWechatLibPackage +### 4.配置 module.json5 + +打开 `entry/src/main/module.json5`,添加: + +```diff +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default" + ], ++ "querySchemes": [ ++ "weixin", ++ ], + ... + } +} +``` + +### 5.配置 CMakeLists 和引入 RNWechatLibPackage 打开 `entry/src/main/cpp/CMakeLists.txt`,添加: @@ -262,7 +284,7 @@ target_link_libraries(rnoh_app PUBLIC rnoh_sample_package) #include "RNOH/PackageProvider.h" #include "generated/RNOHGeneratedPackage.h" #include "SamplePackage.h" -+ #include "BaseReactNativeWechatLibPackage.h" ++ #include "RNWechatLibPackage.h" using namespace rnoh; @@ -270,12 +292,12 @@ std::vector> PackageProvider::getPackages(Package::Cont return { std::make_shared(ctx), std::make_shared(ctx), -+ std::make_shared(ctx), ++ std::make_shared(ctx), }; } ``` -### 5.在 ArkTs 侧引入 WechatLibPackage +### 6.在 ArkTs 侧引入 WechatLibPackage 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: @@ -291,7 +313,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 6.运行 +### 7.运行 点击右上角的 `sync` 按钮 @@ -318,10 +340,12 @@ ohpm install > [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 +> [!TIP] 移动应用跳转至小程序的规则,[请见APP拉起小程序的功能介绍](https://developers.weixin.qq.com/doc/oplatform/Mobile_App/Launching_a_Mini_Program/Launching_a_Mini_Program.html) + | Name | Description | Type | Required | Platform | HarmonyOS Support | | --------------------------------------------- | ------------------ | -------- | -------- | ----------- | ----------------- | | registerApp(appid) | 注册 | Function | no | Android/iOS | yes | -| isWXAppInstalled() | 判断微信是否已安装 | Function | no | Android/iOS | no | +| isWXAppInstalled() | 判断微信是否已安装 | Function | no | Android/iOS | yes | | isWXAppSupportApi() | 检查支持情况 | Function | no | Android/iOS | no | | getApiVersion() | 获取 API 版本号 | Function | no | Android/iOS | no | | openWXApp() | 打开微信 | Function | no | Android/iOS | yes | @@ -335,7 +359,7 @@ ohpm install | shareVideo(ShareVideoMetadata) | 分享视频 | Function | no | Android/iOS | no | | shareWebpage (ShareWebpageMetadata) | 分享网页 | Function | no | Android/iOS | no | | shareMiniProgram(ShareMiniProgramMetadata) | 分享小程序 | Function | no | Android/iOS | no | -| launchMiniProgram (LaunchMiniProgramMetadata) | 跳到小程序 | Function | no | Android/iOS | no | +| launchMiniProgram (LaunchMiniProgramMetadata) | 跳到小程序 | Function | no | Android/iOS | yes | | chooseInvoice (ChooseInvoice) | 选择发票 | Function | no | Android/iOS | no | | pay(payload) | 支付 | Function | no | Android/iOS | yes | | subscribeMessage(SubscribeMessageMetadata) | 一次性订阅消息 | Function | no | Android/iOS | no | @@ -345,8 +369,7 @@ ohpm install ## 其他 - ShareText、ShareImage、ShareLocalImage 只支持分享,不支持收藏,原因为目前微信 Open SDK 还不支持 HarmonyOS 平台的收藏 -- isWXAppInstalled 不支持原因是 HarmonyOS 不支持获取设备上安装的应用列表数据 -- isWXAppSupportApi、getApiVersion、ShareFile、ShareMusic、ShareVideo、ShareWebpage 、ShareMiniProgram、LaunchMiniProgram、ChooseInvoice、subscribeMessage 这些接口目前在 HarmonyOS 微信 Open SDK 还不支持 +- isWXAppSupportApi、getApiVersion、ShareFile、ShareMusic、ShareVideo、ShareWebpage 、ShareMiniProgram、ChooseInvoice、subscribeMessage 这些接口目前在 HarmonyOS 微信 Open SDK 还不支持 ## 开源协议 -- Gitee