react-native-nitro-geolocation 1.1.3 → 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.
- package/README.md +316 -0
- package/android/build.gradle +6 -0
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/AndroidAccuracy.kt +105 -0
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/AndroidHeadingManager.kt +313 -0
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/AndroidLocationSettings.kt +313 -0
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/GetCurrentPosition.kt +46 -45
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/LocationMetadata.kt +26 -0
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/LocationValues.kt +31 -0
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/NitroGeolocation.kt +1025 -140
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/NitroGeolocationCompat.kt +11 -11
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/RequestAuthorization.kt +6 -6
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/WatchPosition.kt +46 -45
- package/ios/CLLocation+GeolocationMetadata.swift +32 -0
- package/ios/LocationManager.swift +205 -51
- package/ios/NitroGeolocation.swift +949 -110
- package/ios/NitroGeolocationCompat.swift +7 -7
- package/nitrogen/generated/android/c++/JAccuracyAuthorization.hpp +61 -0
- package/nitrogen/generated/android/c++/JAndroidAccuracyPreset.hpp +64 -0
- package/nitrogen/generated/android/c++/JAndroidGranularity.hpp +61 -0
- package/nitrogen/generated/android/c++/{JRNConfigurationInternal.hpp → JCompatGeolocationConfigurationInternal.hpp} +10 -10
- package/nitrogen/generated/android/c++/{JGeolocationError.hpp → JCompatGeolocationError.hpp} +10 -10
- package/nitrogen/generated/android/c++/JCompatGeolocationOptions.hpp +105 -0
- package/nitrogen/generated/android/c++/JCompatGeolocationResponse.hpp +67 -0
- package/nitrogen/generated/android/c++/JFunc_void_AccuracyAuthorization.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_CompatGeolocationError.hpp +78 -0
- package/nitrogen/generated/android/c++/JFunc_void_CompatGeolocationResponse.hpp +84 -0
- package/nitrogen/generated/android/c++/JFunc_void_GeolocationResponse.hpp +2 -0
- package/nitrogen/generated/android/c++/JFunc_void_Heading.hpp +78 -0
- package/nitrogen/generated/android/c++/JFunc_void_LocationProviderStatus.hpp +78 -0
- package/nitrogen/generated/android/c++/JFunc_void_PermissionStatus.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_GeocodedLocation_.hpp +97 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_ReverseGeocodedAddress_.hpp +98 -0
- package/nitrogen/generated/android/c++/JGeocodedLocation.hpp +65 -0
- package/nitrogen/generated/android/c++/JGeocodingCoordinates.hpp +61 -0
- package/nitrogen/generated/android/c++/{JModernGeolocationConfiguration.hpp → JGeolocationConfiguration.hpp} +10 -10
- package/nitrogen/generated/android/c++/JGeolocationResponse.hpp +13 -3
- package/nitrogen/generated/android/c++/JHeading.hpp +69 -0
- package/nitrogen/generated/android/c++/JHeadingOptions.hpp +57 -0
- package/nitrogen/generated/android/c++/JHybridNitroGeolocationCompatSpec.cpp +46 -30
- package/nitrogen/generated/android/c++/JHybridNitroGeolocationCompatSpec.hpp +4 -4
- package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.cpp +169 -33
- package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.hpp +14 -3
- package/nitrogen/generated/android/c++/JIOSAccuracyPreset.hpp +73 -0
- package/nitrogen/generated/android/c++/JIOSActivityType.hpp +67 -0
- package/nitrogen/generated/android/c++/JLocationAccuracyOptions.hpp +65 -0
- package/nitrogen/generated/android/c++/JLocationAvailability.hpp +62 -0
- package/nitrogen/generated/android/c++/JLocationProviderStatus.hpp +77 -0
- package/nitrogen/generated/android/c++/JLocationProviderUsed.hpp +67 -0
- package/nitrogen/generated/android/c++/JLocationRequestOptions.hpp +49 -3
- package/nitrogen/generated/android/c++/{JGeolocationOptions.hpp → JLocationSettingsOptions.hpp} +28 -22
- package/nitrogen/generated/android/c++/JReverseGeocodedAddress.hpp +82 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AccuracyAuthorization.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AndroidAccuracyPreset.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AndroidGranularity.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/{RNConfigurationInternal.kt → CompatGeolocationConfigurationInternal.kt} +5 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/{GeolocationError.kt → CompatGeolocationError.kt} +5 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/CompatGeolocationOptions.kt +68 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/CompatGeolocationResponse.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_AccuracyAuthorization.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/{Func_void_GeolocationError.kt → Func_void_CompatGeolocationError.kt} +9 -9
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_CompatGeolocationResponse.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_Heading.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_LocationProviderStatus.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_PermissionStatus.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_std__vector_GeocodedLocation_.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_std__vector_ReverseGeocodedAddress_.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeocodedLocation.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeocodingCoordinates.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/{ModernGeolocationConfiguration.kt → GeolocationConfiguration.kt} +5 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationResponse.kt +9 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Heading.kt +47 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HeadingOptions.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HybridNitroGeolocationCompatSpec.kt +7 -7
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HybridNitroGeolocationSpec.kt +92 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/IOSAccuracyPreset.kt +28 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/IOSActivityType.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationAccuracyOptions.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationAvailability.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProviderStatus.kt +53 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProviderUsed.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationRequestOptions.kt +30 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/{GeolocationOptions.kt → LocationSettingsOptions.kt} +11 -11
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/ReverseGeocodedAddress.kt +56 -0
- package/nitrogen/generated/android/nitrogeolocationOnLoad.cpp +18 -4
- package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.cpp +76 -12
- package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.hpp +519 -77
- package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Umbrella.hpp +61 -12
- package/nitrogen/generated/ios/c++/HybridNitroGeolocationCompatSpecSwift.hpp +28 -16
- package/nitrogen/generated/ios/c++/HybridNitroGeolocationSpecSwift.hpp +131 -13
- package/nitrogen/generated/ios/swift/AccuracyAuthorization.swift +44 -0
- package/nitrogen/generated/ios/swift/AndroidAccuracyPreset.swift +48 -0
- package/nitrogen/generated/ios/swift/AndroidGranularity.swift +44 -0
- package/nitrogen/generated/ios/swift/{RNConfigurationInternal.swift → CompatGeolocationConfigurationInternal.swift} +5 -5
- package/nitrogen/generated/ios/swift/{GeolocationError.swift → CompatGeolocationError.swift} +5 -5
- package/nitrogen/generated/ios/swift/CompatGeolocationOptions.swift +208 -0
- package/nitrogen/generated/ios/swift/CompatGeolocationResponse.swift +34 -0
- package/nitrogen/generated/ios/swift/Func_void_AccuracyAuthorization.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_CompatGeolocationError.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_CompatGeolocationResponse.swift +46 -0
- package/nitrogen/generated/ios/swift/{Func_void_GeolocationError.swift → Func_void_Heading.swift} +11 -11
- package/nitrogen/generated/ios/swift/Func_void_LocationAvailability.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_LocationProviderStatus.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_GeocodedLocation_.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_ReverseGeocodedAddress_.swift +46 -0
- package/nitrogen/generated/ios/swift/GeocodedLocation.swift +52 -0
- package/nitrogen/generated/ios/swift/GeocodingCoordinates.swift +34 -0
- package/nitrogen/generated/ios/swift/{ModernGeolocationConfiguration.swift → GeolocationConfiguration.swift} +5 -5
- package/nitrogen/generated/ios/swift/GeolocationResponse.swift +31 -2
- package/nitrogen/generated/ios/swift/Heading.swift +70 -0
- package/nitrogen/generated/ios/swift/HeadingOptions.swift +42 -0
- package/nitrogen/generated/ios/swift/HybridNitroGeolocationCompatSpec.swift +4 -4
- package/nitrogen/generated/ios/swift/HybridNitroGeolocationCompatSpec_cxx.swift +28 -28
- package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec.swift +14 -3
- package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec_cxx.swift +318 -15
- package/nitrogen/generated/ios/swift/IOSAccuracyPreset.swift +60 -0
- package/nitrogen/generated/ios/swift/IOSActivityType.swift +52 -0
- package/nitrogen/generated/ios/swift/LocationAccuracyOptions.swift +46 -0
- package/nitrogen/generated/ios/swift/LocationAvailability.swift +47 -0
- package/nitrogen/generated/ios/swift/LocationProviderStatus.swift +106 -0
- package/nitrogen/generated/ios/swift/LocationProviderUsed.swift +52 -0
- package/nitrogen/generated/ios/swift/LocationRequestOptions.swift +142 -1
- package/nitrogen/generated/ios/swift/{GeolocationOptions.swift → LocationSettingsOptions.swift} +39 -46
- package/nitrogen/generated/ios/swift/ReverseGeocodedAddress.swift +150 -0
- package/nitrogen/generated/shared/c++/AccuracyAuthorization.hpp +80 -0
- package/nitrogen/generated/shared/c++/AndroidAccuracyPreset.hpp +84 -0
- package/nitrogen/generated/shared/c++/AndroidGranularity.hpp +80 -0
- package/nitrogen/generated/shared/c++/{RNConfigurationInternal.hpp → CompatGeolocationConfigurationInternal.hpp} +11 -11
- package/nitrogen/generated/shared/c++/{GeolocationError.hpp → CompatGeolocationError.hpp} +11 -11
- package/nitrogen/generated/shared/c++/CompatGeolocationOptions.hpp +128 -0
- package/nitrogen/generated/shared/c++/CompatGeolocationResponse.hpp +88 -0
- package/nitrogen/generated/shared/c++/GeocodedLocation.hpp +91 -0
- package/nitrogen/generated/shared/c++/GeocodingCoordinates.hpp +87 -0
- package/nitrogen/generated/shared/c++/{ModernGeolocationConfiguration.hpp → GeolocationConfiguration.hpp} +11 -11
- package/nitrogen/generated/shared/c++/GeolocationResponse.hpp +14 -2
- package/nitrogen/generated/shared/c++/Heading.hpp +95 -0
- package/nitrogen/generated/shared/c++/HeadingOptions.hpp +83 -0
- package/nitrogen/generated/shared/c++/HybridNitroGeolocationCompatSpec.hpp +16 -16
- package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.cpp +11 -0
- package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.hpp +51 -12
- package/nitrogen/generated/shared/c++/IOSAccuracyPreset.hpp +96 -0
- package/nitrogen/generated/shared/c++/IOSActivityType.hpp +88 -0
- package/nitrogen/generated/shared/c++/LocationAccuracyOptions.hpp +92 -0
- package/nitrogen/generated/shared/c++/LocationAvailability.hpp +88 -0
- package/nitrogen/generated/shared/c++/LocationProviderStatus.hpp +103 -0
- package/nitrogen/generated/shared/c++/LocationProviderUsed.hpp +88 -0
- package/nitrogen/generated/shared/c++/LocationRequestOptions.hpp +47 -3
- package/nitrogen/generated/shared/c++/{GeolocationOptions.hpp → LocationSettingsOptions.hpp} +26 -24
- package/nitrogen/generated/shared/c++/ReverseGeocodedAddress.hpp +108 -0
- package/package.json +1 -1
- package/src/NitroGeolocation.nitro.ts +291 -17
- package/src/NitroGeolocationCompat.nitro.ts +12 -12
- package/src/api/geocode.ts +18 -0
- package/src/api/getAccuracyAuthorization.ts +12 -0
- package/src/api/getCurrentPosition.ts +5 -3
- package/src/api/getHeading.ts +13 -0
- package/src/api/getLastKnownPosition.ts +28 -0
- package/src/api/getLocationAvailability.ts +11 -0
- package/src/api/getProviderStatus.ts +16 -0
- package/src/api/hasServicesEnabled.ts +13 -0
- package/src/api/index.ts +11 -0
- package/src/api/requestLocationSettings.ts +29 -0
- package/src/api/requestPermission.ts +3 -1
- package/src/api/requestTemporaryFullAccuracy.ts +21 -0
- package/src/api/reverseGeocode.ts +23 -0
- package/src/api/setConfiguration.ts +8 -4
- package/src/api/watchHeading.ts +19 -0
- package/src/api/watchPosition.ts +2 -2
- package/src/compat/getCurrentPosition.ts +7 -7
- package/src/compat/index.tsx +5 -5
- package/src/compat/requestAuthorization.ts +2 -2
- package/src/compat/setRNConfiguration.ts +7 -5
- package/src/compat/watchPosition.ts +7 -7
- package/src/devtools/getCurrentPosition.ts +5 -3
- package/src/devtools/index.ts +1 -1
- package/src/devtools/watchPosition.ts +6 -7
- package/src/hooks/useWatchPosition.ts +2 -2
- package/src/index.tsx +35 -6
- package/src/publicTypes.ts +96 -0
- package/src/types.ts +113 -37
- package/src/utils/errors.test.ts +65 -0
- package/src/utils/errors.ts +45 -18
- package/src/utils/index.ts +2 -2
- package/src/utils/provider.test.ts +172 -1
- package/src/utils/provider.ts +50 -5
- package/nitrogen/generated/android/c++/JFunc_void_GeolocationError.hpp +0 -78
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NitroGeolocationHybridObject } from "../NitroGeolocationModule";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Check whether device-level location services are enabled.
|
|
5
|
+
*
|
|
6
|
+
* Android: checks the system location service/provider state used by native
|
|
7
|
+
* Android location requests.
|
|
8
|
+
*
|
|
9
|
+
* iOS: maps to `CLLocationManager.locationServicesEnabled()`.
|
|
10
|
+
*/
|
|
11
|
+
export function hasServicesEnabled(): Promise<boolean> {
|
|
12
|
+
return NitroGeolocationHybridObject.hasServicesEnabled();
|
|
13
|
+
}
|
package/src/api/index.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
export { setConfiguration } from "./setConfiguration";
|
|
2
2
|
export { checkPermission } from "./checkPermission";
|
|
3
3
|
export { requestPermission } from "./requestPermission";
|
|
4
|
+
export { hasServicesEnabled } from "./hasServicesEnabled";
|
|
5
|
+
export { getProviderStatus } from "./getProviderStatus";
|
|
6
|
+
export { getLocationAvailability } from "./getLocationAvailability";
|
|
7
|
+
export { requestLocationSettings } from "./requestLocationSettings";
|
|
8
|
+
export { getAccuracyAuthorization } from "./getAccuracyAuthorization";
|
|
9
|
+
export { requestTemporaryFullAccuracy } from "./requestTemporaryFullAccuracy";
|
|
4
10
|
export { getCurrentPosition } from "./getCurrentPosition";
|
|
11
|
+
export { getLastKnownPosition } from "./getLastKnownPosition";
|
|
12
|
+
export { geocode } from "./geocode";
|
|
13
|
+
export { reverseGeocode } from "./reverseGeocode";
|
|
14
|
+
export { getHeading } from "./getHeading";
|
|
15
|
+
export { watchHeading } from "./watchHeading";
|
|
5
16
|
export { watchPosition } from "./watchPosition";
|
|
6
17
|
export { unwatch } from "./unwatch";
|
|
7
18
|
export { stopObserving } from "./stopObserving";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { LocationSettingsOptions } from "../NitroGeolocation.nitro";
|
|
2
|
+
import { NitroGeolocationHybridObject } from "../NitroGeolocationModule";
|
|
3
|
+
import type { LocationProviderStatus } from "../publicTypes";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Android-only settings resolution API.
|
|
7
|
+
*
|
|
8
|
+
* Android: checks whether current device settings satisfy the requested
|
|
9
|
+
* location requirements and shows Android's native settings resolution dialog
|
|
10
|
+
* when available.
|
|
11
|
+
*
|
|
12
|
+
* iOS: does not show a settings dialog and ignores `options`. It resolves with
|
|
13
|
+
* the current Core Location status:
|
|
14
|
+
* - `locationServicesEnabled`: `CLLocationManager.locationServicesEnabled()`
|
|
15
|
+
* - `backgroundModeEnabled`: whether `UIBackgroundModes` contains `location`
|
|
16
|
+
* - `gpsAvailable`, `networkAvailable`, `passiveAvailable`, and
|
|
17
|
+
* `googleLocationAccuracyEnabled`: `undefined`
|
|
18
|
+
*/
|
|
19
|
+
export function requestLocationSettings(
|
|
20
|
+
options?: LocationSettingsOptions
|
|
21
|
+
): Promise<LocationProviderStatus> {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
NitroGeolocationHybridObject.requestLocationSettings(
|
|
24
|
+
resolve,
|
|
25
|
+
reject,
|
|
26
|
+
options
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -17,5 +17,7 @@ import { NitroGeolocationHybridObject } from "../NitroGeolocationModule";
|
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
export function requestPermission(): Promise<PermissionStatus> {
|
|
20
|
-
return
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
NitroGeolocationHybridObject.requestPermission(resolve, reject);
|
|
22
|
+
});
|
|
21
23
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { LocationError } from "../NitroGeolocation.nitro";
|
|
2
|
+
import { NitroGeolocationHybridObject } from "../NitroGeolocationModule";
|
|
3
|
+
import type { AccuracyAuthorization } from "../publicTypes";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Request temporary full location accuracy on iOS.
|
|
7
|
+
*
|
|
8
|
+
* Android resolves with the current accuracy authorization without showing a
|
|
9
|
+
* prompt.
|
|
10
|
+
*/
|
|
11
|
+
export function requestTemporaryFullAccuracy(
|
|
12
|
+
purposeKey: string
|
|
13
|
+
): Promise<AccuracyAuthorization> {
|
|
14
|
+
return new Promise((resolve, reject: (error: LocationError) => void) => {
|
|
15
|
+
NitroGeolocationHybridObject.requestTemporaryFullAccuracy(
|
|
16
|
+
purposeKey,
|
|
17
|
+
resolve,
|
|
18
|
+
reject
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NitroGeolocationHybridObject } from "../NitroGeolocationModule";
|
|
2
|
+
import type {
|
|
3
|
+
GeocodingCoordinates,
|
|
4
|
+
ReverseGeocodedAddress
|
|
5
|
+
} from "../publicTypes";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Convert coordinates into candidate human-readable addresses.
|
|
9
|
+
*
|
|
10
|
+
* Uses the platform geocoder: Android `Geocoder` and iOS `CLGeocoder`.
|
|
11
|
+
* Results and availability depend on platform networking/geocoder services.
|
|
12
|
+
*
|
|
13
|
+
* @param coords - Latitude and longitude to reverse geocode
|
|
14
|
+
* @returns Promise resolving to matching address candidates
|
|
15
|
+
* @throws LocationError if input is invalid or the platform geocoder fails
|
|
16
|
+
*/
|
|
17
|
+
export function reverseGeocode(
|
|
18
|
+
coords: GeocodingCoordinates
|
|
19
|
+
): Promise<ReverseGeocodedAddress[]> {
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
NitroGeolocationHybridObject.reverseGeocode(coords, resolve, reject);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NitroGeolocation } from "../NitroGeolocation.nitro";
|
|
2
2
|
import { NitroGeolocationHybridObject } from "../NitroGeolocationModule";
|
|
3
|
-
import type {
|
|
3
|
+
import type { GeolocationConfiguration } from "../publicTypes";
|
|
4
|
+
|
|
5
|
+
type NitroGeolocationConfiguration = Parameters<
|
|
6
|
+
NitroGeolocation["setConfiguration"]
|
|
7
|
+
>[0];
|
|
4
8
|
|
|
5
9
|
/**
|
|
6
10
|
* Set global geolocation configuration.
|
|
@@ -18,8 +22,8 @@ import type { ModernGeolocationConfiguration } from "../types";
|
|
|
18
22
|
* });
|
|
19
23
|
* ```
|
|
20
24
|
*/
|
|
21
|
-
export function setConfiguration(config:
|
|
22
|
-
const nativeConfig:
|
|
25
|
+
export function setConfiguration(config: GeolocationConfiguration): void {
|
|
26
|
+
const nativeConfig: NitroGeolocationConfiguration = {
|
|
23
27
|
...config,
|
|
24
28
|
locationProvider:
|
|
25
29
|
config.locationProvider === "android"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { LocationError } from "../NitroGeolocation.nitro";
|
|
2
|
+
import { NitroGeolocationHybridObject } from "../NitroGeolocationModule";
|
|
3
|
+
import type { Heading, HeadingOptions } from "../publicTypes";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Start watching platform heading updates.
|
|
7
|
+
*
|
|
8
|
+
* @param success - Called on each heading update
|
|
9
|
+
* @param error - Called when heading is unavailable or options are invalid
|
|
10
|
+
* @param options - Heading watch options
|
|
11
|
+
* @returns Subscription token for cleanup with `unwatch(token)`
|
|
12
|
+
*/
|
|
13
|
+
export function watchHeading(
|
|
14
|
+
success: (heading: Heading) => void,
|
|
15
|
+
error?: (error: LocationError) => void,
|
|
16
|
+
options?: HeadingOptions
|
|
17
|
+
): string {
|
|
18
|
+
return NitroGeolocationHybridObject.watchHeading(success, error, options);
|
|
19
|
+
}
|
package/src/api/watchPosition.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
import { NitroGeolocationHybridObject } from "../NitroGeolocationModule";
|
|
6
6
|
import { isDevtoolsEnabled } from "../devtools";
|
|
7
7
|
import { devtoolsWatchPosition } from "../devtools/watchPosition";
|
|
8
|
-
import type { GeolocationResponse } from "../
|
|
8
|
+
import type { GeolocationResponse } from "../publicTypes";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Start watching for continuous location updates.
|
|
@@ -24,7 +24,7 @@ import type { GeolocationResponse } from "../types";
|
|
|
24
24
|
* const token = watchPosition(
|
|
25
25
|
* (position) => console.log(position.coords),
|
|
26
26
|
* (error) => console.error(error.message),
|
|
27
|
-
* {
|
|
27
|
+
* { accuracy: { android: "high", ios: "best" }, distanceFilter: 10 }
|
|
28
28
|
* );
|
|
29
29
|
*
|
|
30
30
|
* // Later: cleanup
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { NitroGeolocationHybridCompatObject } from "../NitroGeolocationModule";
|
|
2
2
|
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "../
|
|
3
|
+
CompatGeolocationError,
|
|
4
|
+
CompatGeolocationOptions,
|
|
5
|
+
CompatGeolocationResponse
|
|
6
|
+
} from "../publicTypes";
|
|
7
7
|
|
|
8
8
|
export function getCurrentPosition(
|
|
9
|
-
success: (position:
|
|
10
|
-
error?: (error:
|
|
11
|
-
options?:
|
|
9
|
+
success: (position: CompatGeolocationResponse) => void,
|
|
10
|
+
error?: (error: CompatGeolocationError) => void,
|
|
11
|
+
options?: CompatGeolocationOptions
|
|
12
12
|
): void {
|
|
13
13
|
NitroGeolocationHybridCompatObject.getCurrentPosition(
|
|
14
14
|
success,
|
package/src/compat/index.tsx
CHANGED
|
@@ -25,10 +25,10 @@ const Geolocation = {
|
|
|
25
25
|
|
|
26
26
|
// Export types
|
|
27
27
|
export type {
|
|
28
|
-
GeolocationConfiguration,
|
|
29
|
-
GeolocationResponse,
|
|
30
|
-
GeolocationError,
|
|
31
|
-
GeolocationOptions
|
|
32
|
-
} from "../
|
|
28
|
+
CompatGeolocationConfiguration as GeolocationConfiguration,
|
|
29
|
+
CompatGeolocationResponse as GeolocationResponse,
|
|
30
|
+
CompatGeolocationError as GeolocationError,
|
|
31
|
+
CompatGeolocationOptions as GeolocationOptions
|
|
32
|
+
} from "../publicTypes";
|
|
33
33
|
|
|
34
34
|
export default Geolocation;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { NitroGeolocationHybridCompatObject } from "../NitroGeolocationModule";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CompatGeolocationError } from "../publicTypes";
|
|
3
3
|
|
|
4
4
|
export function requestAuthorization(
|
|
5
5
|
success?: () => void,
|
|
6
|
-
error?: (error:
|
|
6
|
+
error?: (error: CompatGeolocationError) => void
|
|
7
7
|
): void {
|
|
8
8
|
NitroGeolocationHybridCompatObject.requestAuthorization(success, error);
|
|
9
9
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CompatGeolocationConfigurationInternal } from "../NitroGeolocationCompat.nitro";
|
|
2
2
|
import { NitroGeolocationHybridCompatObject } from "../NitroGeolocationModule";
|
|
3
|
-
import type {
|
|
3
|
+
import type { CompatGeolocationConfiguration } from "../publicTypes";
|
|
4
4
|
|
|
5
5
|
// Mapping layer: convert "android" to "android_platform" for C++
|
|
6
6
|
function mapConfigToInternal(
|
|
7
|
-
config:
|
|
8
|
-
):
|
|
7
|
+
config: CompatGeolocationConfiguration
|
|
8
|
+
): CompatGeolocationConfigurationInternal {
|
|
9
9
|
return {
|
|
10
10
|
skipPermissionRequests: config.skipPermissionRequests,
|
|
11
11
|
authorizationLevel: config.authorizationLevel,
|
|
@@ -17,7 +17,9 @@ function mapConfigToInternal(
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export function setRNConfiguration(
|
|
20
|
+
export function setRNConfiguration(
|
|
21
|
+
config: CompatGeolocationConfiguration
|
|
22
|
+
): void {
|
|
21
23
|
NitroGeolocationHybridCompatObject.setRNConfiguration(
|
|
22
24
|
mapConfigToInternal(config)
|
|
23
25
|
);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { NitroGeolocationHybridCompatObject } from "../NitroGeolocationModule";
|
|
2
2
|
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "../
|
|
3
|
+
CompatGeolocationError,
|
|
4
|
+
CompatGeolocationOptions,
|
|
5
|
+
CompatGeolocationResponse
|
|
6
|
+
} from "../publicTypes";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Invokes the success callback whenever the location changes.
|
|
@@ -15,9 +15,9 @@ import type {
|
|
|
15
15
|
* @returns watchId - A number that identifies this watch session
|
|
16
16
|
*/
|
|
17
17
|
export function watchPosition(
|
|
18
|
-
success: (position:
|
|
19
|
-
error?: (error:
|
|
20
|
-
options?:
|
|
18
|
+
success: (position: CompatGeolocationResponse) => void,
|
|
19
|
+
error?: (error: CompatGeolocationError) => void,
|
|
20
|
+
options?: CompatGeolocationOptions
|
|
21
21
|
): number {
|
|
22
22
|
return NitroGeolocationHybridCompatObject.watchPosition(
|
|
23
23
|
success,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { GeolocationResponse } from "../
|
|
1
|
+
import type { GeolocationResponse } from "../publicTypes";
|
|
2
|
+
import { LocationErrorCode, createLocationError } from "../utils/errors";
|
|
2
3
|
import { getDevtoolsState } from "./index";
|
|
3
4
|
|
|
4
5
|
export function getDevtoolsCurrentPosition(): Promise<GeolocationResponse> | null {
|
|
@@ -6,9 +7,10 @@ export function getDevtoolsCurrentPosition(): Promise<GeolocationResponse> | nul
|
|
|
6
7
|
if (devtools.position) {
|
|
7
8
|
return Promise.resolve(devtools.position);
|
|
8
9
|
}
|
|
9
|
-
// Devtools
|
|
10
|
+
// Devtools is JS-only, but keep the public rejection shape aligned.
|
|
10
11
|
return Promise.reject(
|
|
11
|
-
|
|
12
|
+
createLocationError(
|
|
13
|
+
LocationErrorCode.INTERNAL_ERROR,
|
|
12
14
|
"Geolocation devtools not connected. Press 'j' in Metro to open devtools and enable the geolocation plugin."
|
|
13
15
|
)
|
|
14
16
|
);
|
package/src/devtools/index.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LocationError } from "../NitroGeolocation.nitro";
|
|
2
|
+
import type { GeolocationResponse } from "../publicTypes";
|
|
3
|
+
import { LocationErrorCode } from "../utils/errors";
|
|
2
4
|
import { getDevtoolsState } from "./index";
|
|
3
5
|
|
|
4
6
|
export function devtoolsWatchPosition(
|
|
5
7
|
success: (position: GeolocationResponse) => void,
|
|
6
|
-
error?: (error:
|
|
8
|
+
error?: (error: LocationError) => void
|
|
7
9
|
): string {
|
|
8
10
|
const devtools = getDevtoolsState();
|
|
9
11
|
|
|
@@ -12,12 +14,9 @@ export function devtoolsWatchPosition(
|
|
|
12
14
|
// Call error callback immediately if provided
|
|
13
15
|
if (error) {
|
|
14
16
|
error({
|
|
15
|
-
code:
|
|
17
|
+
code: LocationErrorCode.POSITION_UNAVAILABLE,
|
|
16
18
|
message:
|
|
17
|
-
"Geolocation devtools not connected. Press 'j' in Metro to open devtools and enable the geolocation plugin."
|
|
18
|
-
PERMISSION_DENIED: 1,
|
|
19
|
-
POSITION_UNAVAILABLE: 2,
|
|
20
|
-
TIMEOUT: 3
|
|
19
|
+
"Geolocation devtools not connected. Press 'j' in Metro to open devtools and enable the geolocation plugin."
|
|
21
20
|
});
|
|
22
21
|
}
|
|
23
22
|
// Return a dummy token that does nothing
|
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
LocationRequestOptions
|
|
5
5
|
} from "../NitroGeolocation.nitro";
|
|
6
6
|
import { unwatch, watchPosition } from "../api";
|
|
7
|
-
import type { GeolocationResponse } from "../
|
|
7
|
+
import type { GeolocationResponse } from "../publicTypes";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Options for useWatchPosition hook.
|
|
@@ -33,7 +33,7 @@ export interface UseWatchPositionOptions extends LocationRequestOptions {
|
|
|
33
33
|
* function LiveTracking() {
|
|
34
34
|
* const { position, error, isWatching } = useWatchPosition({
|
|
35
35
|
* enabled: true,
|
|
36
|
-
*
|
|
36
|
+
* accuracy: { android: "high", ios: "best" },
|
|
37
37
|
* distanceFilter: 10 // Update every 10 meters
|
|
38
38
|
* });
|
|
39
39
|
*
|
package/src/index.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Geolocation API for React Native.
|
|
3
3
|
*
|
|
4
|
-
* This is the main entry point for the
|
|
5
|
-
* For
|
|
4
|
+
* This is the main entry point for the functional API.
|
|
5
|
+
* For compat usage, use: import Geolocation from 'react-native-nitro-geolocation/compat'
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```tsx
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
* async function setup() {
|
|
25
25
|
* const status = await requestPermission();
|
|
26
26
|
* if (status === 'granted') {
|
|
27
|
-
* const position = await getCurrentPosition({
|
|
27
|
+
* const position = await getCurrentPosition({
|
|
28
|
+
* accuracy: { android: 'high', ios: 'best' }
|
|
29
|
+
* });
|
|
28
30
|
* console.log('Position:', position);
|
|
29
31
|
* }
|
|
30
32
|
* }
|
|
@@ -33,7 +35,7 @@
|
|
|
33
35
|
* function LiveTracking() {
|
|
34
36
|
* const { position, error, isWatching } = useWatchPosition({
|
|
35
37
|
* enabled: true,
|
|
36
|
-
*
|
|
38
|
+
* accuracy: { android: 'high', ios: 'best' },
|
|
37
39
|
* distanceFilter: 10
|
|
38
40
|
* });
|
|
39
41
|
*
|
|
@@ -51,7 +53,18 @@ export {
|
|
|
51
53
|
setConfiguration,
|
|
52
54
|
checkPermission,
|
|
53
55
|
requestPermission,
|
|
56
|
+
hasServicesEnabled,
|
|
57
|
+
getProviderStatus,
|
|
58
|
+
getLocationAvailability,
|
|
59
|
+
requestLocationSettings,
|
|
60
|
+
getAccuracyAuthorization,
|
|
61
|
+
requestTemporaryFullAccuracy,
|
|
54
62
|
getCurrentPosition,
|
|
63
|
+
getLastKnownPosition,
|
|
64
|
+
geocode,
|
|
65
|
+
reverseGeocode,
|
|
66
|
+
getHeading,
|
|
67
|
+
watchHeading,
|
|
55
68
|
watchPosition,
|
|
56
69
|
unwatch,
|
|
57
70
|
stopObserving
|
|
@@ -64,16 +77,32 @@ export * from "./hooks";
|
|
|
64
77
|
export type {
|
|
65
78
|
PermissionStatus,
|
|
66
79
|
LocationRequestOptions,
|
|
80
|
+
LocationSettingsOptions,
|
|
67
81
|
LocationError
|
|
68
82
|
} from "./NitroGeolocation.nitro";
|
|
69
83
|
|
|
70
84
|
export type {
|
|
71
85
|
GeolocationResponse,
|
|
72
86
|
GeolocationCoordinates,
|
|
87
|
+
LocationProviderStatus,
|
|
88
|
+
LocationAvailability,
|
|
89
|
+
GeocodingCoordinates,
|
|
90
|
+
GeocodedLocation,
|
|
91
|
+
ReverseGeocodedAddress,
|
|
92
|
+
AndroidAccuracyPreset,
|
|
93
|
+
AndroidGranularity,
|
|
94
|
+
IOSAccuracyPreset,
|
|
95
|
+
AccuracyAuthorization,
|
|
96
|
+
IOSActivityType,
|
|
97
|
+
LocationAccuracyOptions,
|
|
98
|
+
Heading,
|
|
99
|
+
HeadingOptions,
|
|
73
100
|
AuthorizationLevel,
|
|
74
101
|
LocationProvider,
|
|
102
|
+
LocationProviderUsed,
|
|
103
|
+
GeolocationConfiguration,
|
|
75
104
|
ModernGeolocationConfiguration
|
|
76
|
-
} from "./
|
|
105
|
+
} from "./publicTypes";
|
|
77
106
|
|
|
78
107
|
// Pure utility functions (advanced users only)
|
|
79
108
|
export * from "./utils";
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { NitroGeolocation } from "./NitroGeolocation.nitro";
|
|
2
|
+
import type {
|
|
3
|
+
CompatGeolocationConfigurationInternal,
|
|
4
|
+
NitroGeolocationCompat
|
|
5
|
+
} from "./NitroGeolocationCompat.nitro";
|
|
6
|
+
import type {
|
|
7
|
+
AccuracyAuthorization as SchemaAccuracyAuthorization,
|
|
8
|
+
AndroidAccuracyPreset as SchemaAndroidAccuracyPreset,
|
|
9
|
+
AndroidGranularity as SchemaAndroidGranularity,
|
|
10
|
+
GeocodedLocation as SchemaGeocodedLocation,
|
|
11
|
+
GeocodingCoordinates as SchemaGeocodingCoordinates,
|
|
12
|
+
GeolocationResponse as SchemaGeolocationResponse,
|
|
13
|
+
Heading as SchemaHeading,
|
|
14
|
+
HeadingOptions as SchemaHeadingOptions,
|
|
15
|
+
IOSAccuracyPreset as SchemaIOSAccuracyPreset,
|
|
16
|
+
IOSActivityType as SchemaIOSActivityType,
|
|
17
|
+
LocationAccuracyOptions as SchemaLocationAccuracyOptions,
|
|
18
|
+
LocationAvailability as SchemaLocationAvailability,
|
|
19
|
+
LocationProviderStatus as SchemaLocationProviderStatus,
|
|
20
|
+
LocationProviderUsed as SchemaLocationProviderUsed,
|
|
21
|
+
ReverseGeocodedAddress as SchemaReverseGeocodedAddress
|
|
22
|
+
} from "./types";
|
|
23
|
+
|
|
24
|
+
type CallbackValue<TCallback> = TCallback extends (value: infer Value) => void
|
|
25
|
+
? Value
|
|
26
|
+
: never;
|
|
27
|
+
|
|
28
|
+
type CompatGetCurrentPosition = NitroGeolocationCompat["getCurrentPosition"];
|
|
29
|
+
type CompatSuccessCallback = Parameters<CompatGetCurrentPosition>[0];
|
|
30
|
+
type CompatErrorCallback = NonNullable<Parameters<CompatGetCurrentPosition>[1]>;
|
|
31
|
+
type NativeGeolocationConfiguration = Parameters<
|
|
32
|
+
NitroGeolocation["setConfiguration"]
|
|
33
|
+
>[0];
|
|
34
|
+
type NativeLocationProvider = NonNullable<
|
|
35
|
+
NativeGeolocationConfiguration["locationProvider"]
|
|
36
|
+
>;
|
|
37
|
+
|
|
38
|
+
export type GeolocationResponse = SchemaGeolocationResponse;
|
|
39
|
+
export type LocationProviderStatus = SchemaLocationProviderStatus;
|
|
40
|
+
export type LocationAvailability = SchemaLocationAvailability;
|
|
41
|
+
export type GeocodingCoordinates = SchemaGeocodingCoordinates;
|
|
42
|
+
export type GeocodedLocation = SchemaGeocodedLocation;
|
|
43
|
+
export type ReverseGeocodedAddress = SchemaReverseGeocodedAddress;
|
|
44
|
+
export type AndroidAccuracyPreset = SchemaAndroidAccuracyPreset;
|
|
45
|
+
export type AndroidGranularity = SchemaAndroidGranularity;
|
|
46
|
+
export type IOSAccuracyPreset = SchemaIOSAccuracyPreset;
|
|
47
|
+
export type AccuracyAuthorization = SchemaAccuracyAuthorization;
|
|
48
|
+
export type IOSActivityType = SchemaIOSActivityType;
|
|
49
|
+
export type LocationAccuracyOptions = SchemaLocationAccuracyOptions;
|
|
50
|
+
export type Heading = SchemaHeading;
|
|
51
|
+
export type HeadingOptions = SchemaHeadingOptions;
|
|
52
|
+
|
|
53
|
+
export type CompatGeolocationResponse = CallbackValue<CompatSuccessCallback>;
|
|
54
|
+
|
|
55
|
+
export type GeolocationCoordinates = GeolocationResponse["coords"];
|
|
56
|
+
export type LocationProviderUsed = SchemaLocationProviderUsed;
|
|
57
|
+
export type CompatGeolocationError = CallbackValue<CompatErrorCallback>;
|
|
58
|
+
export type CompatGeolocationOptions = NonNullable<
|
|
59
|
+
Parameters<CompatGetCurrentPosition>[2]
|
|
60
|
+
>;
|
|
61
|
+
|
|
62
|
+
export type AuthorizationLevel = NonNullable<
|
|
63
|
+
NativeGeolocationConfiguration["authorizationLevel"]
|
|
64
|
+
>;
|
|
65
|
+
export type LocationProvider =
|
|
66
|
+
| Exclude<NativeLocationProvider, "android_platform">
|
|
67
|
+
| "android";
|
|
68
|
+
|
|
69
|
+
export type GeolocationConfiguration = Omit<
|
|
70
|
+
NativeGeolocationConfiguration,
|
|
71
|
+
"autoRequestPermission" | "locationProvider"
|
|
72
|
+
> & {
|
|
73
|
+
/**
|
|
74
|
+
* @deprecated This option is accepted for backward compatibility only.
|
|
75
|
+
* `setConfiguration()` does not request permission. Call
|
|
76
|
+
* `requestPermission()` explicitly when your app is ready to show the native
|
|
77
|
+
* permission prompt.
|
|
78
|
+
* @default false
|
|
79
|
+
*/
|
|
80
|
+
autoRequestPermission?: boolean;
|
|
81
|
+
|
|
82
|
+
locationProvider?: LocationProvider;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @deprecated Use `GeolocationConfiguration` instead.
|
|
87
|
+
* This alias is kept only for backward compatibility.
|
|
88
|
+
*/
|
|
89
|
+
export type ModernGeolocationConfiguration = GeolocationConfiguration;
|
|
90
|
+
|
|
91
|
+
export type CompatGeolocationConfiguration = Omit<
|
|
92
|
+
CompatGeolocationConfigurationInternal,
|
|
93
|
+
"locationProvider"
|
|
94
|
+
> & {
|
|
95
|
+
locationProvider?: LocationProvider;
|
|
96
|
+
};
|