From e81facc325d275e57d09eee96a5151cd62829fe3 Mon Sep 17 00:00:00 2001
From: Li-2199 <1269001954@qq.com>
Date: Thu, 11 Jul 2024 17:28:32 +0800
Subject: [PATCH 1/2] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0react-native-geol?=
=?UTF-8?q?ocation=E6=96=87=E6=A1=A3=E6=A8=A1=E6=9D=BF=E5=8D=87=E7=BA=A7?=
=?UTF-8?q?=E4=B8=BA0.2.2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
zh-cn/react-native-geolocation.md | 108 +++++++++++++++++++-----------
1 file changed, 68 insertions(+), 40 deletions(-)
diff --git a/zh-cn/react-native-geolocation.md b/zh-cn/react-native-geolocation.md
index 5fd52977..adf76c97 100644
--- a/zh-cn/react-native-geolocation.md
+++ b/zh-cn/react-native-geolocation.md
@@ -1,23 +1,24 @@
-> 模板版本:v0.1.2
+
+> 模板版本:v0.2.2
-
react-native-geolocation
+ @react-native-community/geolocation
-
+
-> [!tip] [Github 地址](https://github.com/react-native-oh-library/react-native-geolocation/tree/sig)
+> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-geolocation/tree/sig)
## 安装与使用
-请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-geolocation Releases](https://github.com/react-native-oh-library/react-native-geolocation/releases),并下载适用版本的 tgz 包。
+请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/geolocation Releases](https://github.com/react-native-oh-library/react-native-geolocation/releases),并下载适用版本的 tgz 包。
进入到工程目录并输入以下命令:
@@ -28,13 +29,13 @@
#### **npm**
```bash
-npm install @react-native-oh-tpl/react-native-geolocation@file:#
+npm install @react-native-oh-tpl/geolocation@file:#
```
#### **yarn**
```bash
-yarn add @react-native-oh-tpl/react-native-geolocation@file:#
+yarn add @react-native-oh-tpl/geolocation@file:#
```
@@ -44,15 +45,22 @@ yarn add @react-native-oh-tpl/react-native-geolocation@file:#
> [!WARNING] 使用时 import 的库名不变。
```js
-// setRNConfiguration 为例
-Geolocation.setRNConfiguration(
- config: {
- skipPermissionRequests: boolean;
- authorizationLevel?: 'always' | 'whenInUse' | 'auto';
- enableBackgroundLocationUpdates?: boolean;
- locationProvider?: 'playServices' | 'android' | 'auto';
- }
-) => void
+import Geolocation from "@react-native-community/geolocation";
+import { Button } from "react-native";
+
+export function GeolocationDemo(): JSX.Element {
+ const tap = () => {
+ Geolocation.setRNConfiguration({
+ skipPermissionRequests: true,
+ authorizationLevel: "auto",
+ enableBackgroundLocationUpdates: true,
+ locationProvider: "auto",
+ });
+ console.log("tap");
+ };
+
+ return ;
+}
```
## Link
@@ -61,6 +69,17 @@ Geolocation.setRNConfiguration(
首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony`
+### 在工程根目录的 `oh-package.json` 添加 overrides 字段
+
+```json
+{
+ ...
+ "overrides": {
+ "@rnoh/react-native-openharmony" : "./react_native_openharmony"
+ }
+}
+```
+
### 引入原生端代码
目前有两种方法:
@@ -68,7 +87,7 @@ Geolocation.setRNConfiguration(
1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法);
2. 直接链接源码。
-方法一:通过 har 包引入
+方法一:通过 har 包引入(推荐)
> [!TIP] har 包位于三方库安装路径的 `harmony` 文件夹下。
@@ -77,8 +96,7 @@ Geolocation.setRNConfiguration(
```json
"dependencies": {
"@rnoh/react-native-openharmony": "file:../react_native_openharmony",
-
- "rnoh-geolocation": "file:../../node_modules/@react-native-oh-tpl/react-native-geolocation/harmony/geolocation.har"
+ "@react-native-oh-tpl/geolocation": "file:../../node_modules/@react-native-oh-tpl/geolocation/harmony/geolocation.har"
}
```
@@ -102,28 +120,38 @@ ohpm install
```diff
project(rnapp)
cmake_minimum_required(VERSION 3.4.1)
+set(CMAKE_SKIP_BUILD_RPATH TRUE)
set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
-set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
+set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp")
+set(LOG_VERBOSITY_LEVEL 1)
+set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
+set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
+set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
+add_compile_definitions(WITH_HITRACE_SYSTRACE)
add_subdirectory("${RNOH_CPP_DIR}" ./rn)
-# RNOH_BEGIN: add_package_subdirectories
+# RNOH_BEGIN: manual_package_linking_1
add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package)
-+ add_subdirectory("${OH_MODULE_DIR}/rnoh-geolocation/src/main/cpp" ./geolocation)
-# RNOH_END: add_package_subdirectories
++ add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/geolocation/src/main/cpp" ./geolocation)
+# RNOH_END: manual_package_linking_1
+
+file(GLOB GENERATED_CPP_FILES "./generated/*.cpp")
add_library(rnoh_app SHARED
+ ${GENERATED_CPP_FILES}
"./PackageProvider.cpp"
"${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
)
target_link_libraries(rnoh_app PUBLIC rnoh)
-# RNOH_BEGIN: link_packages
+# RNOH_BEGIN: manual_package_linking_2
target_link_libraries(rnoh_app PUBLIC rnoh_sample_package)
+ target_link_libraries(rnoh_app PUBLIC rnoh_geolocation)
-# RNOH_END: link_packages
+# RNOH_END: manual_package_linking_2
```
打开 `entry/src/main/cpp/PackageProvider.cpp`,添加:
@@ -149,7 +177,7 @@ std::vector> PackageProvider::getPackages(Package::Cont
```diff
...
-+ import {GeoLocationPackage} from 'rnoh-geolocation/ts';
++ import {GeoLocationPackage} from '@react-native-oh-tpl/geolocation/ts';
export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
return [
@@ -176,7 +204,7 @@ ohpm install
要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。
-请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-geolocation Releases](https://github.com/react-native-oh-library/react-native-geolocation/releases)
+请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/geolocation Releases](https://github.com/react-native-oh-library/react-native-geolocation/releases)
### 权限要求
@@ -187,7 +215,7 @@ ohpm install
"module": {
"requestPermissions": [
{"name": "ohos.permission.INTERNET"},
- {"name": "ohos.permission.LOCATION"},S
+ {"name": "ohos.permission.LOCATION"},
{"name": "ohos.permission.APPROXIMATELY_LOCATION"},
]
}
@@ -196,26 +224,26 @@ ohpm install
## 属性
-> [!tip] "Platform"列表示该属性在原三方库上支持的平台。
+> [!TIP] "Platform"列表示该属性在原三方库上支持的平台。
-> [!tip] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
+> [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
-| Name | Description | Type | Required | Platform | HarmonyOS Support | Notes |
-| -------------------- | -------------------------------------------------------------------------------------- | ----------------------------------------------- | -------- | ----------- | ----------------- | ----------------------------------------------------------------------------------------------------------- |
-| setRNConfiguration | Sets configuration options that will be used in all location requests | function(config) | NO | IOS Android | partially | config 仅支持 skipPermissionRequests |
-| requestAuthorization | Request suitable Location permission | function(success,error) | YES | IOS Android | partially | success 支持,error 仅支持 code 与 message |
-| getCurrentPosition | Invokes the success callback once with the latest location info | function(success(position),error(error),option) | NO | IOS Android | partially | position 中仅 altitudeAccuracy 不支持,option 仅支持 timeout 与 maximumAge,error 仅支持 code 与 message |
-| watchPosition | Invokes the success callback whenever the location changes. Returns a watchId (number) | function(success(postion),error(error),option) | NO | IOS Android | partially | position 中仅 altitudeAccuracy 不支持,error 仅支持 code 与 message,option 仅支持 interval 与 distanceFilter |
-| clearWatch | Clears watch observer by id returned by watchPosition() | function(watchID) | NO | IOS Android | yes | watchID 仅支持默认值 0 |
+| Name | Description | Type | Required | Platform | HarmonyOS Support | Notes |
+| -------------------- | -------------------------------------------------------------------------------------- | ----------------------------------------------- | -------- | ----------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| setRNConfiguration | Sets configuration options that will be used in all location requests | function(config) | NO | iOS Android | partially | config only supports skipPermissionRequests |
+| requestAuthorization | Request suitable Location permission | function(success,error) | YES | iOS Android | partially | error: Only code and message are supported. |
+| getCurrentPosition | Invokes the success callback once with the latest location info | function(success(position),error(error),option) | NO | iOS Android | partially | In position, only altitudeAccuracy is not supported. In option, only timeout and maximumAge are supported. In error, only code and message are supported. |
+| watchPosition | Invokes the success callback whenever the location changes. Returns a watchId (number) | function(success(postion),error(error),option) | NO | iOS Android | partially | In position, only altitudeAccuracy is not supported. In error, only code and message are supported. In option, only interval and distanceFilter are supported. |
+| clearWatch | Clears watch observer by id returned by watchPosition() | function(watchID) | NO | iOS Android | yes | watchID supports only the default value 0. |
## 遗留问题
-- [ ] react-native-geolocation 部分属性未实现 HarmonyOS 化: [issue#I8WRMI](https://gitee.com/react-native-oh-library/usage-docs/issues/I8WRMI)
+- [ ] @react-native-oh-tpl/geolocation 部分属性未完全实现 HarmonyOS 化,maximumAge 延时问题: [issue#6](https://github.com/react-native-oh-library/react-native-geolocation/issues/6)
## 其他
## 开源协议
-本项目基于 [The MIT License(MIT)](https://github.com/react-native-oh-library/react-native-geolocation/blob/sig/LICENSE) ,请自由地享受和参与开源。
+本项目基于 [The MIT License(MIT)](https://github.com/michalchudziak/react-native-geolocation/blob/master/LICENSE) ,请自由地享受和参与开源。
-
\ No newline at end of file
+
--
Gitee
From 44459ffff099002ed0ea6d9f08f3316635eafab6 Mon Sep 17 00:00:00 2001
From: Li-2199 <1269001954@qq.com>
Date: Mon, 15 Jul 2024 17:13:59 +0800
Subject: [PATCH 2/2] =?UTF-8?q?docs:=20=E4=BF=AE=E6=94=B9=E5=8E=9Freact-na?=
=?UTF-8?q?tive-geolocation=E6=96=87=E6=A1=A3md,README=E5=90=8D=E7=A7=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 3 ++-
zh-cn/README.md | 6 ++++--
...geolocation.md => react-native-community-geolocation.md} | 0
3 files changed, 6 insertions(+), 3 deletions(-)
rename zh-cn/{react-native-geolocation.md => react-native-community-geolocation.md} (100%)
diff --git a/README.md b/README.md
index 63bda0a2..9cf6241a 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@
| 4 | [@react-native-community/blur](https://github.com/Kureev/react-native-blur) | 4.4.0 | 是 | [@react-native-oh-tpl/blurReleases](https://github.com/react-native-oh-library/react-native-blur/releases) | [链接](/zh-cn/react-native-community-blur.md) |
| 5 | [@react-native-community/checkbox](https://github.com/react-native-checkbox/react-native-checkbox) | 0.5.16 | 否 | [@react-native-oh-tpl/react-native-checkbox](https://github.com/react-native-oh-library/react-native-checkbox/releases) | [链接](/zh-cn/react-native-community-checkbox.md) |
| 6 | [@react-native-community/datetimepicker](https://github.com/react-native-datetimepicker/datetimepicker) | 7.6.2 | 是 | [@react-native-oh-tpl/datetimepicker](https://github.com/react-native-oh-library/datetimepicker/releases) | [链接](/zh-cn/react-native-community-datetimepicker.md) |
-| 7 | [@react-native-community/geolocation](https://github.com/michalchudziak/react-native-geolocation) | 3.1.0 | 是 | [@react-native-oh-tpl/react-native-geolocation](https://github.com/react-native-oh-library/react-native-geolocation/releases) | [链接](/zh-cn/react-native-geolocation.md) |
+| 7 | [@react-native-community/geolocation](https://github.com/michalchudziak/react-native-geolocation) | 3.1.0 | 是 | [@react-native-oh-tpl/geolocation](https://github.com/react-native-oh-library/react-native-geolocation/releases) | [链接](/zh-cn/react-native-community-geolocation.md) |
| 8 | [@react-native-community/netinfo](https://github.com/react-native-netinfo/react-native-netinfo) | 11.1.0 | 是 | [@react-native-oh-tpl/netinfo](https://github.com/react-native-oh-library/react-native-netinfo/releases) | [链接](/zh-cn/react-native-community-netinfo.md) |
| 9 | [@react-native-community/progress-bar-android](https://github.com/react-native-progress-view/progress-bar-android) | 1.0.4 | 是 | [@react-native-oh-tpl/progress-bar-android](https://github.com/react-native-oh-library/progress-bar-android/releases) | [链接](/zh-cn/react-native-community-progress-bar-android.md) |
| 10 | [@react-native-community/progress-view](https://github.com/react-native-progress-view/progress-view) | 1.4.2 | 是 | [@react-native-oh-tpl/progress-view](https://github.com/react-native-oh-library/progress-view/releases) | [链接](/zh-cn/react-native-community-progress-view.md) |
@@ -179,6 +179,7 @@
| 153 | [react-native-switch-pro](https://github.com/poberwong/react-native-switch-pro) | 1.0.5 | 否 | [@react-native-oh-tpl/react-native-switch-pro](https://github.com/react-native-oh-library/react-native-switch-pro/releases) | [链接](/zh-cn/react-native-switch-pro.md) |
| 154 | [react-native-drop-shadow](https://github.com/hoanglam10499/react-native-drop-shadow) | 1.0.0 | \- | \- | [链接](/zh-cn/react-native-drop-shadow.md) |
| 155 | [react-native-nested-scroll-view](https://github.com/cesardeazevedo/react-native-nested-scroll-view) | 9.0.0 | 否 | [@react-native-oh-tpl/react-native-nested-scroll-view](https://github.com/react-native-oh-library/react-native-nested-scroll-view/releases) | [链接](/zh-cn/react-native-nested-scroll-view.md) |
+
## 社区
[Github Organization: react-native-oh-library](https://github.com/react-native-oh-library)
diff --git a/zh-cn/README.md b/zh-cn/README.md
index 8391c8d7..1abf1161 100644
--- a/zh-cn/README.md
+++ b/zh-cn/README.md
@@ -1,4 +1,5 @@
+
> [!WARNING] 本文档仅用于三方库使用指导,不涉及任何 React Native OpenHarmony 框架的信息,且会随着 React Native OpenHarmony 框架持续迭代更新,当前版本不代表最终展示版本。
# 简介
@@ -31,7 +32,7 @@
| 4 | [@react-native-community/blur](https://github.com/Kureev/react-native-blur) | 4.4.0 | 是 | [@react-native-oh-tpl/blurReleases](https://github.com/react-native-oh-library/react-native-blur/releases) | [链接](/zh-cn/react-native-community-blur.md) |
| 5 | [@react-native-community/checkbox](https://github.com/react-native-checkbox/react-native-checkbox) | 0.5.16 | 否 | [@react-native-oh-tpl/react-native-checkbox](https://github.com/react-native-oh-library/react-native-checkbox/releases) | [链接](/zh-cn/react-native-community-checkbox.md) |
| 6 | [@react-native-community/datetimepicker](https://github.com/react-native-datetimepicker/datetimepicker) | 7.6.2 | 是 | [@react-native-oh-tpl/datetimepicker](https://github.com/react-native-oh-library/datetimepicker/releases) | [链接](/zh-cn/react-native-community-datetimepicker.md) |
-| 7 | [@react-native-community/geolocation](https://github.com/michalchudziak/react-native-geolocation) | 3.1.0 | 是 | [@react-native-oh-tpl/react-native-geolocation](https://github.com/react-native-oh-library/react-native-geolocation/releases) | [链接](/zh-cn/react-native-geolocation.md) |
+| 7 | [@react-native-community/geolocation](https://github.com/michalchudziak/react-native-geolocation) | 3.1.0 | 是 | [@react-native-oh-tpl/geolocation](https://github.com/react-native-oh-library/react-native-geolocation/releases) | [链接](/zh-cn/react-native-community-geolocation.md) |
| 8 | [@react-native-community/netinfo](https://github.com/react-native-netinfo/react-native-netinfo) | 11.1.0 | 是 | [@react-native-oh-tpl/netinfo](https://github.com/react-native-oh-library/react-native-netinfo/releases) | [链接](/zh-cn/react-native-community-netinfo.md) |
| 9 | [@react-native-community/progress-bar-android](https://github.com/react-native-progress-view/progress-bar-android) | 1.0.4 | 是 | [@react-native-oh-tpl/progress-bar-android](https://github.com/react-native-oh-library/progress-bar-android/releases) | [链接](/zh-cn/react-native-community-progress-bar-android.md) |
| 10 | [@react-native-community/progress-view](https://github.com/react-native-progress-view/progress-view) | 1.4.2 | 是 | [@react-native-oh-tpl/progress-view](https://github.com/react-native-oh-library/progress-view/releases) | [链接](/zh-cn/react-native-community-progress-view.md) |
@@ -180,8 +181,9 @@
| 153 | [react-native-switch-pro](https://github.com/poberwong/react-native-switch-pro) | 1.0.5 | 否 | [@react-native-oh-tpl/react-native-switch-pro](https://github.com/react-native-oh-library/react-native-switch-pro/releases) | [链接](/zh-cn/react-native-switch-pro.md) |
| 154 | [react-native-drop-shadow](https://github.com/hoanglam10499/react-native-drop-shadow) | 1.0.0 | \- | \- | [链接](/zh-cn/react-native-drop-shadow.md) |
| 155 | [react-native-nested-scroll-view](https://github.com/cesardeazevedo/react-native-nested-scroll-view) | 9.0.0 | 否 | [@react-native-oh-tpl/react-native-nested-scroll-view](https://github.com/react-native-oh-library/react-native-nested-scroll-view/releases) | [链接](/zh-cn/react-native-nested-scroll-view.md) |
+
## 社区
[Github Organization: react-native-oh-library](https://github.com/react-native-oh-library)
-
\ No newline at end of file
+
diff --git a/zh-cn/react-native-geolocation.md b/zh-cn/react-native-community-geolocation.md
similarity index 100%
rename from zh-cn/react-native-geolocation.md
rename to zh-cn/react-native-community-geolocation.md
--
Gitee