Skip to content

Commit 52258d0

Browse files
authored
Moo 1825/fix get current location (#249)
2 parents 4aa14c2 + 1210925 commit 52258d0

File tree

7 files changed

+32
-47
lines changed

7 files changed

+32
-47
lines changed

Diff for: packages/jsActions/nanoflow-actions-native/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
10+
### Fixed
11+
12+
- We've updated @react-native-community/geolocation to version 3.4.0 to resolve location-related issues.
13+
914
## [5.0.0] Nanoflow Commons - 2024-12-3
15+
1016
### Changed
1117

1218
- Updated @mendix/pluggable-widgets-tools from version v9.0.0 to v10.15.0.

Diff for: packages/jsActions/nanoflow-actions-native/package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@
2525
},
2626
"dependencies": {
2727
"@react-native-async-storage/async-storage": "2.0.0",
28-
"@react-native-community/geolocation": "2.0.2",
28+
"@react-native-community/geolocation": "3.4.0",
2929
"invariant": "^2.2.4",
3030
"js-base64": "~3.7.2",
31-
"react-native-geocoder": "0.5.0",
32-
"react-native-geolocation-service": "5.2.0"
31+
"react-native-geocoder": "0.5.0"
3332
},
3433
"devDependencies": {
3534
"@mendix/pluggable-widgets-tools": "^10.0.1",

Diff for: packages/jsActions/nanoflow-actions-native/src/geolocation/GetCurrentLocation.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import { Big } from "big.js";
99
import Geolocation, {
1010
GeolocationError,
1111
GeolocationOptions,
12-
GeolocationResponse,
13-
GeolocationStatic
12+
GeolocationResponse
1413
} from "@react-native-community/geolocation";
1514

1615
import type { Platform, NativeModules } from "react-native";
@@ -41,11 +40,7 @@ export async function GetCurrentLocation(
4140
// BEGIN USER CODE
4241

4342
let reactNativeModule: { NativeModules: typeof NativeModules; Platform: typeof Platform } | undefined;
44-
let geolocationModule:
45-
| Geolocation
46-
| GeolocationStatic
47-
| typeof import("react-native-geolocation-service")
48-
| undefined;
43+
let geolocationModule: typeof import("@react-native-community/geolocation").default | Geolocation;
4944

5045
if (navigator && navigator.product === "ReactNative") {
5146
reactNativeModule = require("react-native");
@@ -55,7 +50,7 @@ export async function GetCurrentLocation(
5550
}
5651

5752
if (reactNativeModule.NativeModules.RNFusedLocation) {
58-
geolocationModule = (await import("react-native-geolocation-service")).default;
53+
geolocationModule = (await import("@react-native-community/geolocation")).default;
5954
} else if (reactNativeModule.NativeModules.RNCGeolocation) {
6055
geolocationModule = Geolocation;
6156
} else {

Diff for: packages/jsActions/nanoflow-actions-native/src/geolocation/GetCurrentLocationMinimumAccuracy.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import { Big } from "big.js";
99
import Geolocation, {
1010
GeolocationError,
1111
GeolocationOptions,
12-
GeolocationResponse,
13-
GeolocationStatic
12+
GeolocationResponse
1413
} from "@react-native-community/geolocation";
1514

1615
import type { Platform, NativeModules } from "react-native";
@@ -45,11 +44,7 @@ export async function GetCurrentLocationMinimumAccuracy(
4544
// BEGIN USER CODE
4645

4746
let reactNativeModule: { NativeModules: typeof NativeModules; Platform: typeof Platform } | undefined;
48-
let geolocationModule:
49-
| Geolocation
50-
| GeolocationStatic
51-
| typeof import("react-native-geolocation-service")
52-
| undefined;
47+
let geolocationModule: typeof import("@react-native-community/geolocation").default | Geolocation;
5348

5449
if (navigator && navigator.product === "ReactNative") {
5550
reactNativeModule = require("react-native");
@@ -59,7 +54,7 @@ export async function GetCurrentLocationMinimumAccuracy(
5954
}
6055

6156
if (reactNativeModule.NativeModules.RNFusedLocation) {
62-
geolocationModule = (await import("react-native-geolocation-service")).default;
57+
geolocationModule = (await import("@react-native-community/geolocation")).default;
6358
} else if (reactNativeModule.NativeModules.RNCGeolocation) {
6459
geolocationModule = Geolocation;
6560
} else {

Diff for: packages/jsActions/nanoflow-actions-native/src/geolocation/RequestLocationPermission.ts

+12-14
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// - the code between BEGIN USER CODE and END USER CODE
66
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
77
// Other code you write will be lost the next time you deploy the project.
8-
import Geolocation, { GeolocationStatic } from "@react-native-community/geolocation";
8+
import Geolocation, { GeolocationError } from "@react-native-community/geolocation";
99

1010
import type { GeolocationServiceStatic, AuthorizationResult } from "../../typings/Geolocation";
1111

@@ -20,11 +20,7 @@ export async function RequestLocationPermission(): Promise<boolean> {
2020
// BEGIN USER CODE
2121

2222
let reactNativeModule: typeof import("react-native") | undefined;
23-
let geolocationModule:
24-
| Geolocation
25-
| GeolocationStatic
26-
| typeof import("react-native-geolocation-service")
27-
| undefined;
23+
let geolocationModule: typeof import("@react-native-community/geolocation").default;
2824

2925
const hasPermissionIOS = async (): Promise<boolean> => {
3026
const openSetting = (): void => {
@@ -122,13 +118,15 @@ export async function RequestLocationPermission(): Promise<boolean> {
122118
status => status === reactNativeModule?.PermissionsAndroid.RESULTS.GRANTED
123119
)
124120
);
125-
} else if (geolocationModule && (geolocationModule as GeolocationStatic).requestAuthorization) {
126-
try {
127-
(geolocationModule as GeolocationStatic).requestAuthorization();
128-
return Promise.resolve(true);
129-
} catch (error) {
130-
return Promise.reject(error);
131-
}
121+
} else if (geolocationModule) {
122+
geolocationModule.requestAuthorization(
123+
() => {
124+
return Promise.resolve(true);
125+
},
126+
(err: GeolocationError) => {
127+
return Promise.reject(err);
128+
}
129+
);
132130
}
133131

134132
return false;
@@ -142,7 +140,7 @@ export async function RequestLocationPermission(): Promise<boolean> {
142140
}
143141

144142
if (reactNativeModule.NativeModules.RNFusedLocation) {
145-
geolocationModule = (await import("react-native-geolocation-service")).default;
143+
geolocationModule = (await import("@react-native-community/geolocation")).default;
146144
return hasLocationPermission();
147145
} else if (reactNativeModule.NativeModules.RNCGeolocation) {
148146
geolocationModule = Geolocation;

Diff for: packages/jsActions/nanoflow-actions-native/typings/Geolocation.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
watchPosition,
1010
clearWatch,
1111
stopObserving
12-
} from "react-native-geolocation-service";
12+
} from "@react-native-community/geolocation";
1313

1414
type GeolocationServiceStatic = {
1515
getCurrentPosition: typeof getCurrentPosition;

Diff for: yarn.lock

+5-13
Original file line numberDiff line numberDiff line change
@@ -4089,13 +4089,13 @@ __metadata:
40894089
languageName: node
40904090
linkType: hard
40914091

4092-
"@react-native-community/geolocation@npm:2.0.2":
4093-
version: 2.0.2
4094-
resolution: "@react-native-community/geolocation@npm:2.0.2"
4092+
"@react-native-community/geolocation@npm:3.4.0":
4093+
version: 3.4.0
4094+
resolution: "@react-native-community/geolocation@npm:3.4.0"
40954095
peerDependencies:
40964096
react: "*"
40974097
react-native: "*"
4098-
checksum: 10/4722abdbc963cd392c38d6712612a55cf6c933e6c87d523196ca62761ecd9764dd7a6906c7fa4850ea5a2ea35b1997fd09322aff6eac5690d335692c8e83d915
4098+
checksum: 10/e8f9c487dbea6ae0540185f07d92aca68a1efc823ef572492776b7533be9eebe0234374b9a34f1837899a15e98dbd7673e906380442c19313405bccf7f3e42b1
40994099
languageName: node
41004100
linkType: hard
41014101

@@ -13495,13 +13495,12 @@ __metadata:
1349513495
dependencies:
1349613496
"@mendix/pluggable-widgets-tools": "npm:^10.0.1"
1349713497
"@react-native-async-storage/async-storage": "npm:2.0.0"
13498-
"@react-native-community/geolocation": "npm:2.0.2"
13498+
"@react-native-community/geolocation": "npm:3.4.0"
1349913499
eslint: "npm:^7.32.0"
1350013500
invariant: "npm:^2.2.4"
1350113501
js-base64: "npm:~3.7.2"
1350213502
mendix: "npm:~10.0.9976"
1350313503
react-native-geocoder: "npm:0.5.0"
13504-
react-native-geolocation-service: "npm:5.2.0"
1350513504
rollup: "npm:^2.79.2"
1350613505
languageName: unknown
1350713506
linkType: soft
@@ -15500,13 +15499,6 @@ __metadata:
1550015499
languageName: node
1550115500
linkType: hard
1550215501

15503-
"react-native-geolocation-service@npm:5.2.0":
15504-
version: 5.2.0
15505-
resolution: "react-native-geolocation-service@npm:5.2.0"
15506-
checksum: 10/4562ba419c63fa2f4c375ad3aeb3c3f845f5814c7f80fa4eb7f5b875c9296d2615f06a0cd576cf55553baa509007ab2f439fb1f2f2fceb47df15644d7a16ab21
15507-
languageName: node
15508-
linkType: hard
15509-
1551015502
"react-native-gesture-handler@npm:2.16.2":
1551115503
version: 2.16.2
1551215504
resolution: "react-native-gesture-handler@npm:2.16.2"

0 commit comments

Comments
 (0)