react-native-nitro-geolocation 1.1.4 → 1.2.1

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 (186) hide show
  1. package/README.md +97 -9
  2. package/android/build.gradle +6 -0
  3. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/AndroidAccuracy.kt +105 -0
  4. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/AndroidHeadingManager.kt +313 -0
  5. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/AndroidLocationSettings.kt +313 -0
  6. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/GetCurrentPosition.kt +46 -45
  7. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/LocationMetadata.kt +26 -0
  8. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/LocationValues.kt +31 -0
  9. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/NitroGeolocation.kt +1027 -140
  10. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/NitroGeolocationCompat.kt +11 -11
  11. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/RequestAuthorization.kt +6 -6
  12. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/WatchPosition.kt +46 -45
  13. package/ios/CLLocation+GeolocationMetadata.swift +32 -0
  14. package/ios/LocationManager.swift +205 -51
  15. package/ios/NitroGeolocation.swift +949 -110
  16. package/ios/NitroGeolocationCompat.swift +7 -7
  17. package/nitrogen/generated/android/c++/JAccuracyAuthorization.hpp +61 -0
  18. package/nitrogen/generated/android/c++/JAndroidAccuracyPreset.hpp +64 -0
  19. package/nitrogen/generated/android/c++/JAndroidGranularity.hpp +61 -0
  20. package/nitrogen/generated/android/c++/{JRNConfigurationInternal.hpp → JCompatGeolocationConfigurationInternal.hpp} +10 -10
  21. package/nitrogen/generated/android/c++/{JGeolocationError.hpp → JCompatGeolocationError.hpp} +10 -10
  22. package/nitrogen/generated/android/c++/JCompatGeolocationOptions.hpp +105 -0
  23. package/nitrogen/generated/android/c++/JCompatGeolocationResponse.hpp +67 -0
  24. package/nitrogen/generated/android/c++/JFunc_void_AccuracyAuthorization.hpp +77 -0
  25. package/nitrogen/generated/android/c++/JFunc_void_CompatGeolocationError.hpp +78 -0
  26. package/nitrogen/generated/android/c++/JFunc_void_CompatGeolocationResponse.hpp +84 -0
  27. package/nitrogen/generated/android/c++/JFunc_void_GeolocationResponse.hpp +2 -0
  28. package/nitrogen/generated/android/c++/JFunc_void_Heading.hpp +78 -0
  29. package/nitrogen/generated/android/c++/JFunc_void_LocationProviderStatus.hpp +78 -0
  30. package/nitrogen/generated/android/c++/JFunc_void_PermissionStatus.hpp +77 -0
  31. package/nitrogen/generated/android/c++/JFunc_void_std__vector_GeocodedLocation_.hpp +97 -0
  32. package/nitrogen/generated/android/c++/JFunc_void_std__vector_ReverseGeocodedAddress_.hpp +98 -0
  33. package/nitrogen/generated/android/c++/JGeocodedLocation.hpp +65 -0
  34. package/nitrogen/generated/android/c++/JGeocodingCoordinates.hpp +61 -0
  35. package/nitrogen/generated/android/c++/{JModernGeolocationConfiguration.hpp → JGeolocationConfiguration.hpp} +10 -10
  36. package/nitrogen/generated/android/c++/JGeolocationResponse.hpp +13 -3
  37. package/nitrogen/generated/android/c++/JHeading.hpp +69 -0
  38. package/nitrogen/generated/android/c++/JHeadingOptions.hpp +57 -0
  39. package/nitrogen/generated/android/c++/JHybridNitroGeolocationCompatSpec.cpp +46 -30
  40. package/nitrogen/generated/android/c++/JHybridNitroGeolocationCompatSpec.hpp +4 -4
  41. package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.cpp +169 -33
  42. package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.hpp +14 -3
  43. package/nitrogen/generated/android/c++/JIOSAccuracyPreset.hpp +73 -0
  44. package/nitrogen/generated/android/c++/JIOSActivityType.hpp +67 -0
  45. package/nitrogen/generated/android/c++/JLocationAccuracyOptions.hpp +65 -0
  46. package/nitrogen/generated/android/c++/JLocationAvailability.hpp +62 -0
  47. package/nitrogen/generated/android/c++/JLocationProviderStatus.hpp +77 -0
  48. package/nitrogen/generated/android/c++/JLocationProviderUsed.hpp +67 -0
  49. package/nitrogen/generated/android/c++/JLocationRequestOptions.hpp +49 -3
  50. package/nitrogen/generated/android/c++/{JGeolocationOptions.hpp → JLocationSettingsOptions.hpp} +28 -22
  51. package/nitrogen/generated/android/c++/JReverseGeocodedAddress.hpp +82 -0
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AccuracyAuthorization.kt +24 -0
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AndroidAccuracyPreset.kt +25 -0
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AndroidGranularity.kt +24 -0
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/{RNConfigurationInternal.kt → CompatGeolocationConfigurationInternal.kt} +5 -5
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/{GeolocationError.kt → CompatGeolocationError.kt} +5 -5
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/CompatGeolocationOptions.kt +68 -0
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/CompatGeolocationResponse.kt +41 -0
  59. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_AccuracyAuthorization.kt +80 -0
  60. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/{Func_void_GeolocationError.kt → Func_void_CompatGeolocationError.kt} +9 -9
  61. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_CompatGeolocationResponse.kt +80 -0
  62. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_Heading.kt +80 -0
  63. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_LocationProviderStatus.kt +80 -0
  64. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_PermissionStatus.kt +80 -0
  65. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_std__vector_GeocodedLocation_.kt +80 -0
  66. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_std__vector_ReverseGeocodedAddress_.kt +80 -0
  67. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeocodedLocation.kt +44 -0
  68. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeocodingCoordinates.kt +41 -0
  69. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/{ModernGeolocationConfiguration.kt → GeolocationConfiguration.kt} +5 -5
  70. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationResponse.kt +9 -3
  71. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Heading.kt +47 -0
  72. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HeadingOptions.kt +38 -0
  73. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HybridNitroGeolocationCompatSpec.kt +7 -7
  74. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HybridNitroGeolocationSpec.kt +92 -3
  75. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/IOSAccuracyPreset.kt +28 -0
  76. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/IOSActivityType.kt +26 -0
  77. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationAccuracyOptions.kt +41 -0
  78. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationAvailability.kt +41 -0
  79. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProviderStatus.kt +53 -0
  80. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProviderUsed.kt +26 -0
  81. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationRequestOptions.kt +30 -3
  82. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/{GeolocationOptions.kt → LocationSettingsOptions.kt} +11 -11
  83. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/ReverseGeocodedAddress.kt +56 -0
  84. package/nitrogen/generated/android/nitrogeolocationOnLoad.cpp +18 -4
  85. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.cpp +76 -12
  86. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.hpp +519 -77
  87. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Umbrella.hpp +61 -12
  88. package/nitrogen/generated/ios/c++/HybridNitroGeolocationCompatSpecSwift.hpp +28 -16
  89. package/nitrogen/generated/ios/c++/HybridNitroGeolocationSpecSwift.hpp +131 -13
  90. package/nitrogen/generated/ios/swift/AccuracyAuthorization.swift +44 -0
  91. package/nitrogen/generated/ios/swift/AndroidAccuracyPreset.swift +48 -0
  92. package/nitrogen/generated/ios/swift/AndroidGranularity.swift +44 -0
  93. package/nitrogen/generated/ios/swift/{RNConfigurationInternal.swift → CompatGeolocationConfigurationInternal.swift} +5 -5
  94. package/nitrogen/generated/ios/swift/{GeolocationError.swift → CompatGeolocationError.swift} +5 -5
  95. package/nitrogen/generated/ios/swift/CompatGeolocationOptions.swift +208 -0
  96. package/nitrogen/generated/ios/swift/CompatGeolocationResponse.swift +34 -0
  97. package/nitrogen/generated/ios/swift/Func_void_AccuracyAuthorization.swift +46 -0
  98. package/nitrogen/generated/ios/swift/Func_void_CompatGeolocationError.swift +46 -0
  99. package/nitrogen/generated/ios/swift/Func_void_CompatGeolocationResponse.swift +46 -0
  100. package/nitrogen/generated/ios/swift/{Func_void_GeolocationError.swift → Func_void_Heading.swift} +11 -11
  101. package/nitrogen/generated/ios/swift/Func_void_LocationAvailability.swift +46 -0
  102. package/nitrogen/generated/ios/swift/Func_void_LocationProviderStatus.swift +46 -0
  103. package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
  104. package/nitrogen/generated/ios/swift/Func_void_std__vector_GeocodedLocation_.swift +46 -0
  105. package/nitrogen/generated/ios/swift/Func_void_std__vector_ReverseGeocodedAddress_.swift +46 -0
  106. package/nitrogen/generated/ios/swift/GeocodedLocation.swift +52 -0
  107. package/nitrogen/generated/ios/swift/GeocodingCoordinates.swift +34 -0
  108. package/nitrogen/generated/ios/swift/{ModernGeolocationConfiguration.swift → GeolocationConfiguration.swift} +5 -5
  109. package/nitrogen/generated/ios/swift/GeolocationResponse.swift +31 -2
  110. package/nitrogen/generated/ios/swift/Heading.swift +70 -0
  111. package/nitrogen/generated/ios/swift/HeadingOptions.swift +42 -0
  112. package/nitrogen/generated/ios/swift/HybridNitroGeolocationCompatSpec.swift +4 -4
  113. package/nitrogen/generated/ios/swift/HybridNitroGeolocationCompatSpec_cxx.swift +28 -28
  114. package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec.swift +14 -3
  115. package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec_cxx.swift +318 -15
  116. package/nitrogen/generated/ios/swift/IOSAccuracyPreset.swift +60 -0
  117. package/nitrogen/generated/ios/swift/IOSActivityType.swift +52 -0
  118. package/nitrogen/generated/ios/swift/LocationAccuracyOptions.swift +46 -0
  119. package/nitrogen/generated/ios/swift/LocationAvailability.swift +47 -0
  120. package/nitrogen/generated/ios/swift/LocationProviderStatus.swift +106 -0
  121. package/nitrogen/generated/ios/swift/LocationProviderUsed.swift +52 -0
  122. package/nitrogen/generated/ios/swift/LocationRequestOptions.swift +142 -1
  123. package/nitrogen/generated/ios/swift/{GeolocationOptions.swift → LocationSettingsOptions.swift} +39 -46
  124. package/nitrogen/generated/ios/swift/ReverseGeocodedAddress.swift +150 -0
  125. package/nitrogen/generated/shared/c++/AccuracyAuthorization.hpp +80 -0
  126. package/nitrogen/generated/shared/c++/AndroidAccuracyPreset.hpp +84 -0
  127. package/nitrogen/generated/shared/c++/AndroidGranularity.hpp +80 -0
  128. package/nitrogen/generated/shared/c++/{RNConfigurationInternal.hpp → CompatGeolocationConfigurationInternal.hpp} +11 -11
  129. package/nitrogen/generated/shared/c++/{GeolocationError.hpp → CompatGeolocationError.hpp} +11 -11
  130. package/nitrogen/generated/shared/c++/CompatGeolocationOptions.hpp +128 -0
  131. package/nitrogen/generated/shared/c++/CompatGeolocationResponse.hpp +88 -0
  132. package/nitrogen/generated/shared/c++/GeocodedLocation.hpp +91 -0
  133. package/nitrogen/generated/shared/c++/GeocodingCoordinates.hpp +87 -0
  134. package/nitrogen/generated/shared/c++/{ModernGeolocationConfiguration.hpp → GeolocationConfiguration.hpp} +11 -11
  135. package/nitrogen/generated/shared/c++/GeolocationResponse.hpp +14 -2
  136. package/nitrogen/generated/shared/c++/Heading.hpp +95 -0
  137. package/nitrogen/generated/shared/c++/HeadingOptions.hpp +83 -0
  138. package/nitrogen/generated/shared/c++/HybridNitroGeolocationCompatSpec.hpp +16 -16
  139. package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.cpp +11 -0
  140. package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.hpp +51 -12
  141. package/nitrogen/generated/shared/c++/IOSAccuracyPreset.hpp +96 -0
  142. package/nitrogen/generated/shared/c++/IOSActivityType.hpp +88 -0
  143. package/nitrogen/generated/shared/c++/LocationAccuracyOptions.hpp +92 -0
  144. package/nitrogen/generated/shared/c++/LocationAvailability.hpp +88 -0
  145. package/nitrogen/generated/shared/c++/LocationProviderStatus.hpp +103 -0
  146. package/nitrogen/generated/shared/c++/LocationProviderUsed.hpp +88 -0
  147. package/nitrogen/generated/shared/c++/LocationRequestOptions.hpp +47 -3
  148. package/nitrogen/generated/shared/c++/{GeolocationOptions.hpp → LocationSettingsOptions.hpp} +26 -24
  149. package/nitrogen/generated/shared/c++/ReverseGeocodedAddress.hpp +108 -0
  150. package/package.json +1 -1
  151. package/src/NitroGeolocation.nitro.ts +292 -18
  152. package/src/NitroGeolocationCompat.nitro.ts +12 -12
  153. package/src/api/geocode.ts +18 -0
  154. package/src/api/getAccuracyAuthorization.ts +12 -0
  155. package/src/api/getCurrentPosition.ts +5 -3
  156. package/src/api/getHeading.ts +13 -0
  157. package/src/api/getLastKnownPosition.ts +28 -0
  158. package/src/api/getLocationAvailability.ts +11 -0
  159. package/src/api/getProviderStatus.ts +16 -0
  160. package/src/api/hasServicesEnabled.ts +13 -0
  161. package/src/api/index.ts +11 -0
  162. package/src/api/requestLocationSettings.ts +29 -0
  163. package/src/api/requestPermission.ts +3 -1
  164. package/src/api/requestTemporaryFullAccuracy.ts +21 -0
  165. package/src/api/reverseGeocode.ts +23 -0
  166. package/src/api/setConfiguration.ts +8 -4
  167. package/src/api/watchHeading.ts +19 -0
  168. package/src/api/watchPosition.ts +2 -2
  169. package/src/compat/getCurrentPosition.ts +7 -7
  170. package/src/compat/index.tsx +5 -5
  171. package/src/compat/requestAuthorization.ts +2 -2
  172. package/src/compat/setRNConfiguration.ts +7 -5
  173. package/src/compat/watchPosition.ts +7 -7
  174. package/src/devtools/getCurrentPosition.ts +5 -3
  175. package/src/devtools/index.ts +1 -1
  176. package/src/devtools/watchPosition.ts +6 -7
  177. package/src/hooks/useWatchPosition.ts +2 -2
  178. package/src/index.tsx +35 -6
  179. package/src/publicTypes.ts +108 -0
  180. package/src/types.ts +113 -37
  181. package/src/utils/errors.test.ts +65 -0
  182. package/src/utils/errors.ts +45 -18
  183. package/src/utils/index.ts +2 -2
  184. package/src/utils/provider.test.ts +172 -1
  185. package/src/utils/provider.ts +50 -5
  186. package/nitrogen/generated/android/c++/JFunc_void_GeolocationError.hpp +0 -78
@@ -0,0 +1,16 @@
1
+ import { NitroGeolocationHybridObject } from "../NitroGeolocationModule";
2
+ import type { LocationProviderStatus } from "../publicTypes";
3
+
4
+ /**
5
+ * Get native provider/settings status for the current device.
6
+ *
7
+ * Android: returns device-level service state plus provider availability
8
+ * (`gpsAvailable`, `networkAvailable`, `passiveAvailable`) and Google Location
9
+ * Accuracy state when Google Play Services exposes it.
10
+ *
11
+ * iOS: returns Core Location service availability and whether the app declares
12
+ * background location mode. Android-specific provider fields are `undefined`.
13
+ */
14
+ export function getProviderStatus(): Promise<LocationProviderStatus> {
15
+ return NitroGeolocationHybridObject.getProviderStatus();
16
+ }
@@ -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 NitroGeolocationHybridObject.requestPermission();
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 { ModernGeolocationConfiguration as NitroModernGeolocationConfiguration } from "../NitroGeolocation.nitro";
1
+ import type { NitroGeolocation } from "../NitroGeolocation.nitro";
2
2
  import { NitroGeolocationHybridObject } from "../NitroGeolocationModule";
3
- import type { ModernGeolocationConfiguration } from "../types";
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: ModernGeolocationConfiguration): void {
22
- const nativeConfig: NitroModernGeolocationConfiguration = {
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
+ }
@@ -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 "../types";
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
- * { enableHighAccuracy: true, distanceFilter: 10 }
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
- GeolocationError,
4
- GeolocationOptions,
5
- GeolocationResponse
6
- } from "../types";
3
+ CompatGeolocationError,
4
+ CompatGeolocationOptions,
5
+ CompatGeolocationResponse
6
+ } from "../publicTypes";
7
7
 
8
8
  export function getCurrentPosition(
9
- success: (position: GeolocationResponse) => void,
10
- error?: (error: GeolocationError) => void,
11
- options?: GeolocationOptions
9
+ success: (position: CompatGeolocationResponse) => void,
10
+ error?: (error: CompatGeolocationError) => void,
11
+ options?: CompatGeolocationOptions
12
12
  ): void {
13
13
  NitroGeolocationHybridCompatObject.getCurrentPosition(
14
14
  success,
@@ -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 "../types";
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 { GeolocationError } from "../types";
2
+ import type { CompatGeolocationError } from "../publicTypes";
3
3
 
4
4
  export function requestAuthorization(
5
5
  success?: () => void,
6
- error?: (error: GeolocationError) => void
6
+ error?: (error: CompatGeolocationError) => void
7
7
  ): void {
8
8
  NitroGeolocationHybridCompatObject.requestAuthorization(success, error);
9
9
  }
@@ -1,11 +1,11 @@
1
- import type { RNConfigurationInternal } from "../NitroGeolocationCompat.nitro";
1
+ import type { CompatGeolocationConfigurationInternal } from "../NitroGeolocationCompat.nitro";
2
2
  import { NitroGeolocationHybridCompatObject } from "../NitroGeolocationModule";
3
- import type { GeolocationConfiguration } from "../types";
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: GeolocationConfiguration
8
- ): RNConfigurationInternal {
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(config: GeolocationConfiguration): void {
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
- GeolocationError,
4
- GeolocationOptions,
5
- GeolocationResponse
6
- } from "../types";
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: GeolocationResponse) => void,
19
- error?: (error: GeolocationError) => void,
20
- options?: GeolocationOptions
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 "../types";
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 not connected - throw error
10
+ // Devtools is JS-only, but keep the public rejection shape aligned.
10
11
  return Promise.reject(
11
- new Error(
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
  );
@@ -1,4 +1,4 @@
1
- import type { GeolocationResponse } from "../types";
1
+ import type { GeolocationResponse } from "../publicTypes";
2
2
 
3
3
  declare const __DEV__: boolean;
4
4
 
@@ -1,9 +1,11 @@
1
- import type { GeolocationError, GeolocationResponse } from "../types";
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: GeolocationError) => void
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: 2, // POSITION_UNAVAILABLE
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 "../types";
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
- * enableHighAccuracy: true,
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
- * Modern Geolocation API for React Native.
2
+ * Geolocation API for React Native.
3
3
  *
4
- * This is the main entry point for the modern, functional API.
5
- * For legacy compatibility, use: import Geolocation from 'react-native-nitro-geolocation/compat'
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({ enableHighAccuracy: true });
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
- * enableHighAccuracy: true,
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 "./types";
105
+ } from "./publicTypes";
77
106
 
78
107
  // Pure utility functions (advanced users only)
79
108
  export * from "./utils";
@@ -0,0 +1,108 @@
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
+ /**
83
+ * Android location provider.
84
+ *
85
+ * `auto` currently uses Android's platform `LocationManager` by default.
86
+ * Set `playServices` explicitly to use Google Play Services fused location.
87
+ */
88
+ locationProvider?: LocationProvider;
89
+ };
90
+
91
+ /**
92
+ * @deprecated Use `GeolocationConfiguration` instead.
93
+ * This alias is kept only for backward compatibility.
94
+ */
95
+ export type ModernGeolocationConfiguration = GeolocationConfiguration;
96
+
97
+ export type CompatGeolocationConfiguration = Omit<
98
+ CompatGeolocationConfigurationInternal,
99
+ "locationProvider"
100
+ > & {
101
+ /**
102
+ * Android location provider.
103
+ *
104
+ * `auto` currently uses Android's platform `LocationManager` by default.
105
+ * Set `playServices` explicitly to use Google Play Services fused location.
106
+ */
107
+ locationProvider?: LocationProvider;
108
+ };