react-native-nitro-geolocation 1.2.0 β 1.2.2
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
CHANGED
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/react-native-nitro-geolocation)
|
|
4
4
|
|
|
5
|
-
**
|
|
5
|
+
**Nitro-powered geolocation for modern React Native apps**
|
|
6
6
|
|
|
7
|
-
A
|
|
7
|
+
A native iOS/Android geolocation module for React Native 0.75+ and New
|
|
8
|
+
Architecture apps. Start by replacing
|
|
9
|
+
[`@react-native-community/geolocation`](https://github.com/michalchudziak/react-native-geolocation)
|
|
10
|
+
with `/compat`, then move to a typed Modern API when you are ready.
|
|
8
11
|
|
|
9
12
|
- π― **Simple functional API** β Direct function calls, no complex abstractions
|
|
10
|
-
- β‘ **JSI-powered performance** β Direct native calls without
|
|
11
|
-
- π **
|
|
13
|
+
- β‘ **JSI-powered performance** β Direct native calls without Bridge overhead
|
|
14
|
+
- π **Compat API** β Drop-in compatible with the core native community API
|
|
12
15
|
- π§Ή **Automatic cleanup** β No manual subscription management
|
|
13
16
|
- π± **Consistent behavior** across iOS and Android
|
|
14
17
|
- π οΈ **DevTools Plugin** β Mock locations with interactive map (Rozenite)
|
|
@@ -24,6 +27,24 @@ Full documentation available at:
|
|
|
24
27
|
|
|
25
28
|
---
|
|
26
29
|
|
|
30
|
+
## When should I use this?
|
|
31
|
+
|
|
32
|
+
| Use case | Recommendation |
|
|
33
|
+
|---|---|
|
|
34
|
+
| Bare React Native 0.75+ app | Use Nitro Geolocation |
|
|
35
|
+
| Migrating from `@react-native-community/geolocation` | Start with `/compat` |
|
|
36
|
+
| New Architecture / Nitro-based app | Recommended |
|
|
37
|
+
| Expo development build or custom native build | Supported with native setup |
|
|
38
|
+
| Expo managed app without native rebuild | Use `expo-location` |
|
|
39
|
+
| Web support required | Use `@react-native-community/geolocation` or `expo-location` for now |
|
|
40
|
+
| Full background tracking / geofencing | Use a dedicated background-location library |
|
|
41
|
+
|
|
42
|
+
Web is not supported in `v1.2.x`. The community package handles web by
|
|
43
|
+
delegating to the browser `navigator.geolocation` API; this package currently
|
|
44
|
+
targets native Nitro bindings. A `/compat` web fallback is planned for `v1.3`.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
27
48
|
## π§ Introduction
|
|
28
49
|
|
|
29
50
|
React Native Nitro Geolocation provides **two APIs** to fit your needs:
|
|
@@ -121,7 +142,8 @@ function LocationTracker() {
|
|
|
121
142
|
|
|
122
143
|
### 2. Compat API (Compatibility)
|
|
123
144
|
|
|
124
|
-
|
|
145
|
+
Drop-in compatible with the core native
|
|
146
|
+
`@react-native-community/geolocation` API:
|
|
125
147
|
|
|
126
148
|
```tsx
|
|
127
149
|
import Geolocation from "react-native-nitro-geolocation/compat";
|
|
@@ -136,6 +158,19 @@ const watchId = Geolocation.watchPosition((position) => console.log(position));
|
|
|
136
158
|
Geolocation.clearWatch(watchId);
|
|
137
159
|
```
|
|
138
160
|
|
|
161
|
+
#### Compat API coverage
|
|
162
|
+
|
|
163
|
+
| Community API | Nitro `/compat` | Notes |
|
|
164
|
+
|---|---:|---|
|
|
165
|
+
| `setRNConfiguration` | Supported | Android `auto` currently maps to the platform provider; set `playServices` explicitly for fused location. |
|
|
166
|
+
| `requestAuthorization` | Supported | iOS authorization follows configured `Info.plist` keys and `authorizationLevel`. |
|
|
167
|
+
| `getCurrentPosition` | Supported | Keeps the legacy callback and error shape. |
|
|
168
|
+
| `watchPosition` | Supported | Returns a numeric watch id. |
|
|
169
|
+
| `clearWatch` | Supported | Clears a watch id from `watchPosition`. |
|
|
170
|
+
| `stopObserving` | Supported | Preserved for legacy cleanup compatibility. |
|
|
171
|
+
| `navigator.geolocation` polyfill | Not supported in `v1.2.x` | Planned for `v1.3`. |
|
|
172
|
+
| Web | Not supported in `v1.2.x` | Planned as a `/compat` browser fallback in `v1.3`. |
|
|
173
|
+
|
|
139
174
|
---
|
|
140
175
|
|
|
141
176
|
## β‘ Quick Start
|
|
@@ -188,7 +223,34 @@ Optional (for background):
|
|
|
188
223
|
|
|
189
224
|
---
|
|
190
225
|
|
|
191
|
-
### 4.
|
|
226
|
+
### 4. Android Reliability
|
|
227
|
+
|
|
228
|
+
- Uses Google Play Services fused location when `locationProvider:
|
|
229
|
+
"playServices"` is set.
|
|
230
|
+
- Keeps `locationProvider: "auto"` on Android's platform `LocationManager` by
|
|
231
|
+
default. Set `playServices` explicitly when you want fused location behavior.
|
|
232
|
+
- Supports native settings resolution through `requestLocationSettings`.
|
|
233
|
+
- Supports approximate/coarse location handling through permissions and
|
|
234
|
+
Android `granularity`.
|
|
235
|
+
- Supports explicit cached reads through `getLastKnownPosition`.
|
|
236
|
+
- Provides structured Modern API errors such as `PLAY_SERVICE_NOT_AVAILABLE`,
|
|
237
|
+
`SETTINGS_NOT_SATISFIED`, and `TIMEOUT`.
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
### 5. Expo Development Builds
|
|
242
|
+
|
|
243
|
+
This package requires native Nitro bindings, so it is not an Expo Go module.
|
|
244
|
+
Use Expo prebuild, a development build, or another custom native build flow,
|
|
245
|
+
then apply the same iOS and Android native permission setup shown above.
|
|
246
|
+
|
|
247
|
+
Managed Expo apps that cannot rebuild native code should use `expo-location`.
|
|
248
|
+
See the [Expo development build guide](https://react-native-nitro-geolocation.pages.dev/guide/expo-development-build)
|
|
249
|
+
for the supported setup path.
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
### 6. Development Tools (Optional)
|
|
192
254
|
|
|
193
255
|
#### DevTools Plugin (Rozenite)
|
|
194
256
|
|
|
@@ -238,7 +300,7 @@ function App() {
|
|
|
238
300
|
|
|
239
301
|
---
|
|
240
302
|
|
|
241
|
-
###
|
|
303
|
+
### 7. Usage
|
|
242
304
|
|
|
243
305
|
#### Modern API (Recommended)
|
|
244
306
|
|
|
@@ -291,12 +353,67 @@ Geolocation.clearWatch(watchId);
|
|
|
291
353
|
|
|
292
354
|
## π Migration from `@react-native-community/geolocation`
|
|
293
355
|
|
|
294
|
-
|
|
356
|
+
The safest migration is two-step: switch imports to `/compat` first, verify
|
|
357
|
+
the app, then move call sites to the Modern API where it improves ownership,
|
|
358
|
+
permission timing, cache behavior, or Android settings handling.
|
|
359
|
+
|
|
360
|
+
For Modern API migration, install the Agent Skills-compatible migration
|
|
361
|
+
playbook from this repository. It is migration assistance for coding agents, not
|
|
362
|
+
a fully automatic migration. The skill first runs a package-manager-aware
|
|
363
|
+
compat bootstrap script that installs the Nitro packages, rewrites legacy import
|
|
364
|
+
sources to `/compat`, and removes `@react-native-community/geolocation`. After
|
|
365
|
+
that safe mechanical step, it guides the agent to refactor compat call sites to
|
|
366
|
+
Modern API best practices using explicit criteria for permission timing, React
|
|
367
|
+
lifecycle ownership, watch cleanup, cache-vs-fresh location reads, accuracy, and
|
|
368
|
+
Android provider/settings handling.
|
|
369
|
+
|
|
370
|
+
With the Vercel Labs `skills` CLI:
|
|
371
|
+
|
|
372
|
+
```bash
|
|
373
|
+
npx skills add jingjing2222/react-native-nitro-geolocation --skill react-native-nitro-geolocation-modern-migration
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
The skill source is
|
|
377
|
+
[`skills/react-native-nitro-geolocation-modern-migration/SKILL.md`](https://github.com/jingjing2222/react-native-nitro-geolocation/tree/main/skills/react-native-nitro-geolocation-modern-migration).
|
|
378
|
+
The bundled bootstrap script is
|
|
379
|
+
[`skills/react-native-nitro-geolocation-modern-migration/scripts/migrate-to-compat.mjs`](https://github.com/jingjing2222/react-native-nitro-geolocation/tree/main/skills/react-native-nitro-geolocation-modern-migration/scripts/migrate-to-compat.mjs).
|
|
380
|
+
|
|
381
|
+
For a drop-in compatibility migration, change the import to use `/compat`:
|
|
382
|
+
|
|
295
383
|
```diff
|
|
296
384
|
- import Geolocation from '@react-native-community/geolocation';
|
|
297
385
|
+ import Geolocation from 'react-native-nitro-geolocation/compat';
|
|
298
386
|
```
|
|
299
387
|
|
|
388
|
+
Then migrate individual call sites to the Modern API:
|
|
389
|
+
|
|
390
|
+
```diff
|
|
391
|
+
- Geolocation.getCurrentPosition(onSuccess, onError, {
|
|
392
|
+
- enableHighAccuracy: true,
|
|
393
|
+
- timeout: 15000,
|
|
394
|
+
- });
|
|
395
|
+
+ const position = await getCurrentPosition({
|
|
396
|
+
+ accuracy: { android: "high", ios: "best" },
|
|
397
|
+
+ timeout: 15000,
|
|
398
|
+
+ });
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
See the [migration demo](https://react-native-nitro-geolocation.pages.dev/guide/migration-demo)
|
|
402
|
+
for the full community import β `/compat` β Modern API path.
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## Benchmark scope
|
|
407
|
+
|
|
408
|
+
The benchmark measures cached `getCurrentPosition` reads over 1000 iterations Γ
|
|
409
|
+
5 runs on an iPhone 14 Pro with React Native 0.81.4. It measures the
|
|
410
|
+
JS-to-native path for cached locations, not cold GPS acquisition, permission
|
|
411
|
+
dialogs, provider availability, or OS throttling.
|
|
412
|
+
|
|
413
|
+
For cached location reads, Nitro removes Bridge overhead. This does not make GPS
|
|
414
|
+
acquisition itself 22x faster; it makes cached reads and the JS-to-native call
|
|
415
|
+
path cheaper.
|
|
416
|
+
|
|
300
417
|
---
|
|
301
418
|
|
|
302
419
|
## π Learn More
|
|
@@ -305,6 +422,8 @@ Change the import to use `/compat` β 100% API compatible:
|
|
|
305
422
|
- [Quick Start Guide](https://react-native-nitro-geolocation.pages.dev/guide/quick-start)
|
|
306
423
|
- [Modern API Reference](https://react-native-nitro-geolocation.pages.dev/guide/modern-api)
|
|
307
424
|
- [Compat API Reference](https://react-native-nitro-geolocation.pages.dev/guide/compat-api)
|
|
425
|
+
- [Migration Demo](https://react-native-nitro-geolocation.pages.dev/guide/migration-demo)
|
|
426
|
+
- [Expo Development Build Guide](https://react-native-nitro-geolocation.pages.dev/guide/expo-development-build)
|
|
308
427
|
- [DevTools Plugin Guide](https://react-native-nitro-geolocation.pages.dev/guide/devtools)
|
|
309
428
|
- [Why Nitro Module?](https://react-native-nitro-geolocation.pages.dev/guide/why-nitro-module)
|
|
310
429
|
- [Benchmark Results](https://react-native-nitro-geolocation.pages.dev/guide/benchmark)
|
|
@@ -747,6 +747,8 @@ class NitroGeolocation(
|
|
|
747
747
|
// MARK: - Helper Functions - Provider Selection
|
|
748
748
|
|
|
749
749
|
private fun requiresPlayServices(): Boolean {
|
|
750
|
+
// TODO: Switch auto/default Android provider selection to prefer
|
|
751
|
+
// Google Play Services when available.
|
|
750
752
|
return configuration?.locationProvider == LocationProvider.PLAYSERVICES
|
|
751
753
|
}
|
|
752
754
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-geolocation",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.2.2",
|
|
4
|
+
"description": "Nitro-powered native geolocation for modern React Native apps",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"source": "src/index",
|
|
7
7
|
"exports": {
|
|
@@ -26,6 +26,22 @@
|
|
|
26
26
|
},
|
|
27
27
|
"author": "jingjing2222",
|
|
28
28
|
"license": "MIT",
|
|
29
|
+
"keywords": [
|
|
30
|
+
"react-native",
|
|
31
|
+
"geolocation",
|
|
32
|
+
"location",
|
|
33
|
+
"gps",
|
|
34
|
+
"ios",
|
|
35
|
+
"android",
|
|
36
|
+
"nitro",
|
|
37
|
+
"nitro-modules",
|
|
38
|
+
"jsi",
|
|
39
|
+
"new-architecture",
|
|
40
|
+
"fused-location",
|
|
41
|
+
"geocoding",
|
|
42
|
+
"heading",
|
|
43
|
+
"expo-dev-client"
|
|
44
|
+
],
|
|
29
45
|
"homepage": "https://react-native-nitro-geolocation.pages.dev",
|
|
30
46
|
"repository": {
|
|
31
47
|
"type": "git",
|
|
@@ -67,7 +67,7 @@ export interface GeolocationConfiguration {
|
|
|
67
67
|
* Android: Location provider
|
|
68
68
|
* - 'playServices': Use Google Play Services (fused location)
|
|
69
69
|
* - 'android_platform': Use Android platform LocationManager
|
|
70
|
-
* - 'auto':
|
|
70
|
+
* - 'auto': Use Android platform LocationManager by default
|
|
71
71
|
*/
|
|
72
72
|
locationProvider?: LocationProvider;
|
|
73
73
|
}
|
package/src/publicTypes.ts
CHANGED
|
@@ -79,6 +79,12 @@ export type GeolocationConfiguration = Omit<
|
|
|
79
79
|
*/
|
|
80
80
|
autoRequestPermission?: boolean;
|
|
81
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
|
+
*/
|
|
82
88
|
locationProvider?: LocationProvider;
|
|
83
89
|
};
|
|
84
90
|
|
|
@@ -92,5 +98,11 @@ export type CompatGeolocationConfiguration = Omit<
|
|
|
92
98
|
CompatGeolocationConfigurationInternal,
|
|
93
99
|
"locationProvider"
|
|
94
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
|
+
*/
|
|
95
107
|
locationProvider?: LocationProvider;
|
|
96
108
|
};
|