react-native-nitro-location-tracking 0.1.9 → 0.1.10

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 (25) hide show
  1. package/README.md +37 -0
  2. package/android/build.gradle +1 -0
  3. package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/NitroLocationTracking.kt +10 -0
  4. package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/PermissionStatusMonitor.kt +85 -0
  5. package/ios/LocationEngine.swift +19 -0
  6. package/ios/NitroLocationTracking.swift +6 -0
  7. package/lib/module/index.js.map +1 -1
  8. package/lib/typescript/src/NitroLocationTracking.nitro.d.ts +2 -0
  9. package/lib/typescript/src/NitroLocationTracking.nitro.d.ts.map +1 -1
  10. package/lib/typescript/src/index.d.ts +1 -1
  11. package/lib/typescript/src/index.d.ts.map +1 -1
  12. package/nitrogen/generated/android/c++/JFunc_void_PermissionStatus.hpp +77 -0
  13. package/nitrogen/generated/android/c++/JHybridNitroLocationTrackingSpec.cpp +5 -0
  14. package/nitrogen/generated/android/c++/JHybridNitroLocationTrackingSpec.hpp +1 -0
  15. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/Func_void_PermissionStatus.kt +80 -0
  16. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/HybridNitroLocationTrackingSpec.kt +9 -0
  17. package/nitrogen/generated/android/nitrolocationtrackingOnLoad.cpp +2 -0
  18. package/nitrogen/generated/ios/c++/HybridNitroLocationTrackingSpecSwift.hpp +6 -0
  19. package/nitrogen/generated/ios/swift/HybridNitroLocationTrackingSpec.swift +1 -0
  20. package/nitrogen/generated/ios/swift/HybridNitroLocationTrackingSpec_cxx.swift +16 -0
  21. package/nitrogen/generated/shared/c++/HybridNitroLocationTrackingSpec.cpp +1 -0
  22. package/nitrogen/generated/shared/c++/HybridNitroLocationTrackingSpec.hpp +1 -0
  23. package/package.json +1 -1
  24. package/src/NitroLocationTracking.nitro.ts +3 -0
  25. package/src/index.tsx +1 -0
package/README.md CHANGED
@@ -531,6 +531,42 @@ async function setup() {
531
531
  | iOS | Calls `requestAlwaysAuthorization()`. If permission is already determined, resolves immediately with current status. If `start()` was called before permission was granted, tracking auto-starts once the user allows. |
532
532
  | Android | Uses React Native's `PermissionAwareActivity` to show the system permission dialog for `ACCESS_FINE_LOCATION` + `ACCESS_COARSE_LOCATION`. Resolves with the resulting status after the user responds. |
533
533
 
534
+ ### Permission Change Listener
535
+
536
+ Listen for permission changes in real time. The callback fires whenever the user changes the location permission (via the system dialog, the Settings app, or MDM policy changes):
537
+
538
+ ```tsx
539
+ import NitroLocationModule from 'react-native-nitro-location-tracking';
540
+
541
+ // Register a listener — fires whenever the permission status changes
542
+ NitroLocationModule.onPermissionStatusChange((status) => {
543
+ console.log('Permission changed to:', status);
544
+ // status: 'notDetermined' | 'denied' | 'restricted' | 'whenInUse' | 'always'
545
+
546
+ switch (status) {
547
+ case 'always':
548
+ console.log('Background location granted — full tracking available');
549
+ break;
550
+ case 'whenInUse':
551
+ console.log('Foreground only — background tracking may not work');
552
+ break;
553
+ case 'denied':
554
+ Alert.alert('Location Required', 'Please re-enable location in Settings');
555
+ break;
556
+ case 'restricted':
557
+ console.warn('Location restricted by parental controls or MDM');
558
+ break;
559
+ }
560
+ });
561
+ ```
562
+
563
+ **Platform behavior:**
564
+
565
+ | Platform | Mechanism | When the callback fires |
566
+ | -------- | --------- | ----------------------- |
567
+ | iOS | `locationManagerDidChangeAuthorization` delegate | Immediately when the user changes permission (system dialog, Settings, MDM) |
568
+ | Android | `ProcessLifecycleOwner` lifecycle observer | When the app returns to foreground after the user changes permission in Settings |
569
+
534
570
  ## API Reference
535
571
 
536
572
  ### Types
@@ -671,6 +707,7 @@ type PermissionStatus =
671
707
  | `onProviderStatusChange(callback)` | `void` | Register GPS/network provider status callback |
672
708
  | `getLocationPermissionStatus()` | `PermissionStatus` | Check current location permission without prompting |
673
709
  | `requestLocationPermission()` | `Promise<PermissionStatus>` | Request location permission and return the resulting status |
710
+ | `onPermissionStatusChange(callback)` | `void` | Register a callback that fires when location permission status changes |
674
711
  | `showLocalNotification(title, body)` | `void` | Show a local notification |
675
712
  | `updateForegroundNotification(title, body)` | `void` | Update the foreground service notification |
676
713
  | `destroy()` | `void` | Stop tracking and disconnect |
@@ -119,4 +119,5 @@ dependencies {
119
119
  implementation "com.squareup.okhttp3:okhttp:4.12.0"
120
120
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0"
121
121
  implementation "androidx.core:core-ktx:1.15.0"
122
+ implementation "androidx.lifecycle:lifecycle-process:2.8.7"
122
123
  }
@@ -26,6 +26,7 @@ class NitroLocationTracking : HybridNitroLocationTrackingSpec() {
26
26
  private var notificationService: NotificationService? = null
27
27
  private var geofenceManager: GeofenceManager? = null
28
28
  private var providerStatusMonitor: ProviderStatusMonitor? = null
29
+ private var permissionStatusMonitor: PermissionStatusMonitor? = null
29
30
 
30
31
  private var locationCallback: ((LocationData) -> Unit)? = null
31
32
  private var motionCallback: ((Boolean) -> Unit)? = null
@@ -34,6 +35,7 @@ class NitroLocationTracking : HybridNitroLocationTrackingSpec() {
34
35
  private var geofenceCallback: ((GeofenceEvent, String) -> Unit)? = null
35
36
  private var speedAlertCallback: ((SpeedAlertType, Double) -> Unit)? = null
36
37
  private var providerStatusCallback: ((LocationProviderStatus, LocationProviderStatus) -> Unit)? = null
38
+ private var permissionStatusCallback: ((PermissionStatus) -> Unit)? = null
37
39
 
38
40
  private var locationConfig: LocationConfig? = null
39
41
 
@@ -50,6 +52,7 @@ class NitroLocationTracking : HybridNitroLocationTrackingSpec() {
50
52
  notificationService = NotificationService(context)
51
53
  geofenceManager = GeofenceManager(context)
52
54
  providerStatusMonitor = ProviderStatusMonitor(context)
55
+ permissionStatusMonitor = PermissionStatusMonitor(context)
53
56
  locationEngine?.dbWriter = dbWriter
54
57
  connectionManager.dbWriter = dbWriter
55
58
  Log.d(TAG, "Components initialized successfully")
@@ -286,6 +289,12 @@ class NitroLocationTracking : HybridNitroLocationTrackingSpec() {
286
289
  return PermissionStatus.ALWAYS
287
290
  }
288
291
 
292
+ override fun onPermissionStatusChange(callback: (status: PermissionStatus) -> Unit) {
293
+ permissionStatusCallback = callback
294
+ ensureInitialized()
295
+ permissionStatusMonitor?.setCallback(callback)
296
+ }
297
+
289
298
  override fun requestLocationPermission(): Promise<PermissionStatus> {
290
299
  return Promise.async {
291
300
  suspendCoroutine { cont ->
@@ -379,5 +388,6 @@ class NitroLocationTracking : HybridNitroLocationTrackingSpec() {
379
388
  notificationService?.stopForegroundService()
380
389
  geofenceManager?.destroy()
381
390
  providerStatusMonitor?.destroy()
391
+ permissionStatusMonitor?.destroy()
382
392
  }
383
393
  }
@@ -0,0 +1,85 @@
1
+ package com.margelo.nitro.nitrolocationtracking
2
+
3
+ import android.content.Context
4
+ import android.content.pm.PackageManager
5
+ import android.os.Build
6
+ import android.util.Log
7
+ import androidx.core.content.ContextCompat
8
+ import androidx.lifecycle.DefaultLifecycleObserver
9
+ import androidx.lifecycle.LifecycleOwner
10
+ import androidx.lifecycle.ProcessLifecycleOwner
11
+
12
+ /**
13
+ * Monitors location‐permission changes by comparing the permission status
14
+ * every time the app comes to the foreground (`ON_START`).
15
+ *
16
+ * Android has no broadcast for permission changes, so consuming the
17
+ * lifecycle is the standard approach (same as react-native-permissions).
18
+ */
19
+ class PermissionStatusMonitor(private val context: Context) {
20
+
21
+ companion object {
22
+ private const val TAG = "PermissionStatusMonitor"
23
+ }
24
+
25
+ private var callback: ((PermissionStatus) -> Unit)? = null
26
+ private var lastStatus: PermissionStatus? = null
27
+
28
+ private val lifecycleObserver = object : DefaultLifecycleObserver {
29
+ override fun onStart(owner: LifecycleOwner) {
30
+ checkAndNotify()
31
+ }
32
+ }
33
+
34
+ fun setCallback(callback: (PermissionStatus) -> Unit) {
35
+ this.callback = callback
36
+ // Capture the current status so we only fire on actual changes
37
+ lastStatus = getCurrentPermissionStatus()
38
+
39
+ // Observe the process lifecycle (app foreground / background)
40
+ try {
41
+ ProcessLifecycleOwner.get().lifecycle.addObserver(lifecycleObserver)
42
+ Log.d(TAG, "Registered lifecycle observer for permission changes")
43
+ } catch (e: Exception) {
44
+ Log.e(TAG, "Failed to register lifecycle observer: ${e.message}")
45
+ }
46
+ }
47
+
48
+ private fun checkAndNotify() {
49
+ val current = getCurrentPermissionStatus()
50
+ if (current != lastStatus) {
51
+ Log.d(TAG, "Permission status changed: $lastStatus -> $current")
52
+ lastStatus = current
53
+ callback?.invoke(current)
54
+ }
55
+ }
56
+
57
+ private fun getCurrentPermissionStatus(): PermissionStatus {
58
+ val fineGranted = ContextCompat.checkSelfPermission(
59
+ context, android.Manifest.permission.ACCESS_FINE_LOCATION
60
+ ) == PackageManager.PERMISSION_GRANTED
61
+
62
+ if (!fineGranted) {
63
+ return PermissionStatus.DENIED
64
+ }
65
+
66
+ // Fine location granted — check background
67
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
68
+ val bgGranted = ContextCompat.checkSelfPermission(
69
+ context, android.Manifest.permission.ACCESS_BACKGROUND_LOCATION
70
+ ) == PackageManager.PERMISSION_GRANTED
71
+ return if (bgGranted) PermissionStatus.ALWAYS else PermissionStatus.WHENINUSE
72
+ }
73
+
74
+ // Pre-Android 10: fine location = always
75
+ return PermissionStatus.ALWAYS
76
+ }
77
+
78
+ fun destroy() {
79
+ try {
80
+ ProcessLifecycleOwner.get().lifecycle.removeObserver(lifecycleObserver)
81
+ } catch (_: Exception) {}
82
+ callback = null
83
+ lastStatus = null
84
+ }
85
+ }
@@ -22,6 +22,7 @@ class LocationEngine: NSObject, CLLocationManagerDelegate {
22
22
  let speedMonitor = SpeedMonitor()
23
23
  let tripCalculator = TripCalculator()
24
24
  var providerStatusCallback: ((LocationProviderStatus, LocationProviderStatus) -> Void)?
25
+ var permissionStatusCallback: ((PermissionStatus) -> Void)?
25
26
 
26
27
  /// The most recently received location from Core Location (for distance calculations)
27
28
  var lastCLLocation: CLLocation? {
@@ -212,6 +213,24 @@ class LocationEngine: NSObject, CLLocationManagerDelegate {
212
213
  }
213
214
  }
214
215
 
216
+ // Notify JS about permission status change
217
+ let permStatus: PermissionStatus
218
+ switch authStatus {
219
+ case .notDetermined:
220
+ permStatus = .notdetermined
221
+ case .restricted:
222
+ permStatus = .restricted
223
+ case .denied:
224
+ permStatus = .denied
225
+ case .authorizedWhenInUse:
226
+ permStatus = .wheninuse
227
+ case .authorizedAlways:
228
+ permStatus = .always
229
+ @unknown default:
230
+ permStatus = .notdetermined
231
+ }
232
+ permissionStatusCallback?(permStatus)
233
+
215
234
  let enabled = CLLocationManager.locationServicesEnabled()
216
235
  let status: LocationProviderStatus = enabled ? .enabled : .disabled
217
236
  providerStatusCallback?(status, status)
@@ -16,6 +16,7 @@ class NitroLocationTracking: HybridNitroLocationTrackingSpec {
16
16
  private var geofenceCallback: ((GeofenceEvent, String) -> Void)?
17
17
  private var speedAlertCallback: ((SpeedAlertType, Double) -> Void)?
18
18
  private var providerStatusCallback: ((LocationProviderStatus, LocationProviderStatus) -> Void)?
19
+ private var permissionStatusCallback: ((PermissionStatus) -> Void)?
19
20
  private var permissionPromise: Promise<PermissionStatus>?
20
21
 
21
22
  override init() {
@@ -236,6 +237,11 @@ class NitroLocationTracking: HybridNitroLocationTrackingSpec {
236
237
  return promise
237
238
  }
238
239
 
240
+ func onPermissionStatusChange(callback: @escaping (PermissionStatus) -> Void) throws {
241
+ permissionStatusCallback = callback
242
+ locationEngine.permissionStatusCallback = callback
243
+ }
244
+
239
245
  // MARK: - Distance Utilities
240
246
 
241
247
  func getDistanceBetween(lat1: Double, lon1: Double, lat2: Double, lon2: Double) throws -> Double {
@@ -1 +1 @@
1
- {"version":3,"names":["useState","useEffect","useCallback","useRef","NitroModules","NitroLocationModule","createHybridObject","requestLocationPermission","LocationSmoother","shortestRotation","calculateBearing","useDriverLocation","config","location","setLocation","isMoving","setIsMoving","isTracking","setIsTracking","configJson","JSON","stringify","trackingRef","parsed","parse","configure","onLocation","onMotionChange","current","stopTracking","startTracking","useRideConnection","connectionState","setConnectionState","lastMessage","setLastMessage","configureConnection","onConnectionStateChange","onMessage","disconnectWebSocket","connect","connectWebSocket","disconnect","send","m","sendMessage"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,SAAS,EAAEC,WAAW,EAAEC,MAAM,QAAQ,OAAO;AAChE,SAASC,YAAY,QAAQ,4BAA4B;AAQzD,MAAMC,mBAAmB,GACvBD,YAAY,CAACE,kBAAkB,CAC7B,uBACF,CAAC;AAEH,eAAeD,mBAAmB;AAClC,SAASE,yBAAyB,QAAQ,wBAAqB;AAC/D,SAASC,gBAAgB,QAAQ,uBAAoB;AACrD,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,cAAW;AAC9D;;AAkBA,OAAO,SAASC,iBAAiBA,CAACC,MAAsB,EAAE;EACxD,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGd,QAAQ,CAAsB,IAAI,CAAC;EACnE,MAAM,CAACe,QAAQ,EAAEC,WAAW,CAAC,GAAGhB,QAAQ,CAAC,KAAK,CAAC;EAC/C,MAAM,CAACiB,UAAU,EAAEC,aAAa,CAAC,GAAGlB,QAAQ,CAAC,KAAK,CAAC;;EAEnD;EACA,MAAMmB,UAAU,GAAGC,IAAI,CAACC,SAAS,CAACT,MAAM,CAAC;;EAEzC;EACA,MAAMU,WAAW,GAAGnB,MAAM,CAAC,KAAK,CAAC;EAEjCF,SAAS,CAAC,MAAM;IACd,MAAMsB,MAAM,GAAGH,IAAI,CAACI,KAAK,CAACL,UAAU,CAAmB;IACvDd,mBAAmB,CAACoB,SAAS,CAACF,MAAM,CAAC;IACrClB,mBAAmB,CAACqB,UAAU,CAACZ,WAAW,CAAC;IAC3CT,mBAAmB,CAACsB,cAAc,CAACX,WAAW,CAAC;IAC/C,OAAO,MAAM;MACX,IAAIM,WAAW,CAACM,OAAO,EAAE;QACvBvB,mBAAmB,CAACwB,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C,mBAAmB,CAAC,CAAC,EAC/C,EACF,CAAC;IACDI,IAAI,EAAEzC,WAAW,CAAE0C,CAAS,IAAKvC,mBAAmB,CAACwC,WAAW,CAACD,CAAC,CAAC,EAAE,EAAE;EACzE,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["useState","useEffect","useCallback","useRef","NitroModules","NitroLocationModule","createHybridObject","requestLocationPermission","LocationSmoother","shortestRotation","calculateBearing","useDriverLocation","config","location","setLocation","isMoving","setIsMoving","isTracking","setIsTracking","configJson","JSON","stringify","trackingRef","parsed","parse","configure","onLocation","onMotionChange","current","stopTracking","startTracking","useRideConnection","connectionState","setConnectionState","lastMessage","setLastMessage","configureConnection","onConnectionStateChange","onMessage","disconnectWebSocket","connect","connectWebSocket","disconnect","send","m","sendMessage"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,SAAS,EAAEC,WAAW,EAAEC,MAAM,QAAQ,OAAO;AAChE,SAASC,YAAY,QAAQ,4BAA4B;AAQzD,MAAMC,mBAAmB,GACvBD,YAAY,CAACE,kBAAkB,CAC7B,uBACF,CAAC;AAEH,eAAeD,mBAAmB;AAClC,SAASE,yBAAyB,QAAQ,wBAAqB;AAC/D,SAASC,gBAAgB,QAAQ,uBAAoB;AACrD,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,cAAW;AAC9D;;AAmBA,OAAO,SAASC,iBAAiBA,CAACC,MAAsB,EAAE;EACxD,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGd,QAAQ,CAAsB,IAAI,CAAC;EACnE,MAAM,CAACe,QAAQ,EAAEC,WAAW,CAAC,GAAGhB,QAAQ,CAAC,KAAK,CAAC;EAC/C,MAAM,CAACiB,UAAU,EAAEC,aAAa,CAAC,GAAGlB,QAAQ,CAAC,KAAK,CAAC;;EAEnD;EACA,MAAMmB,UAAU,GAAGC,IAAI,CAACC,SAAS,CAACT,MAAM,CAAC;;EAEzC;EACA,MAAM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IAC/D5B,mBAAmB,CAACiC,SAAS,CAACH,cAAc,CAAC;IAC7C,OAAO,MAAM;MACX9B,mBAAmB,CAACkC,mBAAmB,CAAC,CAAC;IAC3C,CAAC;EACH,CAAC,EAAE,CAAC3B,MAAM,CAAC,CAAC;EAEZ,OAAO;IACLoB,eAAe;IACfE,WAAW;IACXM,OAAO,EAAEtC,WAAW,CAAC,MAAMG,mBAAmB,CAACoC,gBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC;IACtEC,UAAU,EAAExC,WAAW,CACrB,MAAMG,mBAAmB,CAACkC,mBAAmB,CAAC,CAAC,EAC/C,EACF,CAAC;IACDI,IAAI,EAAEzC,WAAW,CAAE0C,CAAS,IAAKvC,mBAAmB,CAACwC,WAAW,CAACD,CAAC,CAAC,EAAE,EAAE;EACzE,CAAC;AACH","ignoreList":[]}
@@ -61,6 +61,7 @@ export interface TripStats {
61
61
  export type LocationProviderStatus = 'enabled' | 'disabled';
62
62
  export type ProviderStatusCallback = (gps: LocationProviderStatus, network: LocationProviderStatus) => void;
63
63
  export type PermissionStatus = 'notDetermined' | 'denied' | 'restricted' | 'whenInUse' | 'always';
64
+ export type PermissionStatusCallback = (status: PermissionStatus) => void;
64
65
  export interface NitroLocationTracking extends HybridObject<{
65
66
  ios: 'swift';
66
67
  android: 'kotlin';
@@ -97,6 +98,7 @@ export interface NitroLocationTracking extends HybridObject<{
97
98
  onProviderStatusChange(callback: ProviderStatusCallback): void;
98
99
  getLocationPermissionStatus(): PermissionStatus;
99
100
  requestLocationPermission(): Promise<PermissionStatus>;
101
+ onPermissionStatusChange(callback: PermissionStatusCallback): void;
100
102
  getDistanceBetween(lat1: number, lon1: number, lat2: number, lon2: number): number;
101
103
  getDistanceToGeofence(regionId: string): number;
102
104
  showLocalNotification(title: string, body: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"NitroLocationTracking.nitro.d.ts","sourceRoot":"","sources":["../../../src/NitroLocationTracking.nitro.ts"],"names":[],"mappings":"AAAA,O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,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAGhD,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACzD,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAGhE,OAAO,IAAI,IAAI,CAAC;CACjB"}
@@ -4,7 +4,7 @@ export default NitroLocationModule;
4
4
  export { requestLocationPermission } from './requestPermission';
5
5
  export { LocationSmoother } from './LocationSmoother';
6
6
  export { shortestRotation, calculateBearing } from './bearing';
7
- export type { NitroLocationTracking, LocationData, LocationConfig, ConnectionConfig, GeofenceRegion, GeofenceEvent, GeofenceCallback, SpeedConfig, SpeedAlertType, SpeedAlertCallback, TripStats, LocationProviderStatus, ProviderStatusCallback, PermissionStatus, } from './NitroLocationTracking.nitro';
7
+ export type { NitroLocationTracking, LocationData, LocationConfig, ConnectionConfig, GeofenceRegion, GeofenceEvent, GeofenceCallback, SpeedConfig, SpeedAlertType, SpeedAlertCallback, TripStats, LocationProviderStatus, ProviderStatusCallback, PermissionStatus, PermissionStatusCallback, } from './NitroLocationTracking.nitro';
8
8
  export declare function useDriverLocation(config: LocationConfig): {
9
9
  location: LocationData | null;
10
10
  isMoving: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,gBAAgB,EACjB,MAAM,+BAA+B,CAAC;AAEvC,QAAA,MAAM,mBAAmB,uBAGtB,CAAC;AAEJ,eAAe,mBAAmB,CAAC;AACnC,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE/D,YAAY,EACV,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,SAAS,EACT,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AAEvC,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc;;;;;;EAuCvD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB;;;;;cAuBhC,MAAM;EAE/B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,gBAAgB,EACjB,MAAM,+BAA+B,CAAC;AAEvC,QAAA,MAAM,mBAAmB,uBAGtB,CAAC;AAEJ,eAAe,mBAAmB,CAAC;AACnC,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE/D,YAAY,EACV,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,SAAS,EACT,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AAEvC,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc;;;;;;EAuCvD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB;;;;;cAuBhC,MAAM;EAE/B"}
@@ -0,0 +1,77 @@
1
+ ///
2
+ /// JFunc_void_PermissionStatus.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include <functional>
12
+
13
+ #include "PermissionStatus.hpp"
14
+ #include <functional>
15
+ #include <NitroModules/JNICallable.hpp>
16
+ #include "JPermissionStatus.hpp"
17
+
18
+ namespace margelo::nitro::nitrolocationtracking {
19
+
20
+ using namespace facebook;
21
+
22
+ /**
23
+ * Represents the Java/Kotlin callback `(status: PermissionStatus) -> Unit`.
24
+ * This can be passed around between C++ and Java/Kotlin.
25
+ */
26
+ struct JFunc_void_PermissionStatus: public jni::JavaClass<JFunc_void_PermissionStatus> {
27
+ public:
28
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrolocationtracking/Func_void_PermissionStatus;";
29
+
30
+ public:
31
+ /**
32
+ * Invokes the function this `JFunc_void_PermissionStatus` instance holds through JNI.
33
+ */
34
+ void invoke(PermissionStatus status) const {
35
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JPermissionStatus> /* status */)>("invoke");
36
+ method(self(), JPermissionStatus::fromCpp(status));
37
+ }
38
+ };
39
+
40
+ /**
41
+ * An implementation of Func_void_PermissionStatus that is backed by a C++ implementation (using `std::function<...>`)
42
+ */
43
+ class JFunc_void_PermissionStatus_cxx final: public jni::HybridClass<JFunc_void_PermissionStatus_cxx, JFunc_void_PermissionStatus> {
44
+ public:
45
+ static jni::local_ref<JFunc_void_PermissionStatus::javaobject> fromCpp(const std::function<void(PermissionStatus /* status */)>& func) {
46
+ return JFunc_void_PermissionStatus_cxx::newObjectCxxArgs(func);
47
+ }
48
+
49
+ public:
50
+ /**
51
+ * Invokes the C++ `std::function<...>` this `JFunc_void_PermissionStatus_cxx` instance holds.
52
+ */
53
+ void invoke_cxx(jni::alias_ref<JPermissionStatus> status) {
54
+ _func(status->toCpp());
55
+ }
56
+
57
+ public:
58
+ [[nodiscard]]
59
+ inline const std::function<void(PermissionStatus /* status */)>& getFunction() const {
60
+ return _func;
61
+ }
62
+
63
+ public:
64
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrolocationtracking/Func_void_PermissionStatus_cxx;";
65
+ static void registerNatives() {
66
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_PermissionStatus_cxx::invoke_cxx)});
67
+ }
68
+
69
+ private:
70
+ explicit JFunc_void_PermissionStatus_cxx(const std::function<void(PermissionStatus /* status */)>& func): _func(func) { }
71
+
72
+ private:
73
+ friend HybridBase;
74
+ std::function<void(PermissionStatus /* status */)> _func;
75
+ };
76
+
77
+ } // namespace margelo::nitro::nitrolocationtracking
@@ -69,6 +69,7 @@ namespace margelo::nitro::nitrolocationtracking { enum class LocationProviderSta
69
69
  #include "LocationProviderStatus.hpp"
70
70
  #include "JFunc_void_LocationProviderStatus_LocationProviderStatus.hpp"
71
71
  #include "JLocationProviderStatus.hpp"
72
+ #include "JFunc_void_PermissionStatus.hpp"
72
73
 
73
74
  namespace margelo::nitro::nitrolocationtracking {
74
75
 
@@ -281,6 +282,10 @@ namespace margelo::nitro::nitrolocationtracking {
281
282
  return __promise;
282
283
  }();
283
284
  }
285
+ void JHybridNitroLocationTrackingSpec::onPermissionStatusChange(const std::function<void(PermissionStatus /* status */)>& callback) {
286
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_PermissionStatus::javaobject> /* callback */)>("onPermissionStatusChange_cxx");
287
+ method(_javaPart, JFunc_void_PermissionStatus_cxx::fromCpp(callback));
288
+ }
284
289
  double JHybridNitroLocationTrackingSpec::getDistanceBetween(double lat1, double lon1, double lat2, double lon2) {
285
290
  static const auto method = javaClassStatic()->getMethod<double(double /* lat1 */, double /* lon1 */, double /* lat2 */, double /* lon2 */)>("getDistanceBetween");
286
291
  auto __result = method(_javaPart, lat1, lon1, lat2, lon2);
@@ -87,6 +87,7 @@ namespace margelo::nitro::nitrolocationtracking {
87
87
  void onProviderStatusChange(const std::function<void(LocationProviderStatus /* gps */, LocationProviderStatus /* network */)>& callback) override;
88
88
  PermissionStatus getLocationPermissionStatus() override;
89
89
  std::shared_ptr<Promise<PermissionStatus>> requestLocationPermission() override;
90
+ void onPermissionStatusChange(const std::function<void(PermissionStatus /* status */)>& callback) override;
90
91
  double getDistanceBetween(double lat1, double lon1, double lat2, double lon2) override;
91
92
  double getDistanceToGeofence(const std::string& regionId) override;
92
93
  void showLocalNotification(const std::string& title, const std::string& body) override;
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// Func_void_PermissionStatus.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.nitrolocationtracking
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+ import dalvik.annotation.optimization.FastNative
14
+
15
+
16
+ /**
17
+ * Represents the JavaScript callback `(status: enum) => void`.
18
+ * This can be either implemented in C++ (in which case it might be a callback coming from JS),
19
+ * or in Kotlin/Java (in which case it is a native callback).
20
+ */
21
+ @DoNotStrip
22
+ @Keep
23
+ @Suppress("ClassName", "RedundantUnitReturnType")
24
+ fun interface Func_void_PermissionStatus: (PermissionStatus) -> Unit {
25
+ /**
26
+ * Call the given JS callback.
27
+ * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
28
+ */
29
+ @DoNotStrip
30
+ @Keep
31
+ override fun invoke(status: PermissionStatus): Unit
32
+ }
33
+
34
+ /**
35
+ * Represents the JavaScript callback `(status: enum) => void`.
36
+ * This is implemented in C++, via a `std::function<...>`.
37
+ * The callback might be coming from JS.
38
+ */
39
+ @DoNotStrip
40
+ @Keep
41
+ @Suppress(
42
+ "KotlinJniMissingFunction", "unused",
43
+ "RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
44
+ "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
45
+ )
46
+ class Func_void_PermissionStatus_cxx: Func_void_PermissionStatus {
47
+ @DoNotStrip
48
+ @Keep
49
+ private val mHybridData: HybridData
50
+
51
+ @DoNotStrip
52
+ @Keep
53
+ private constructor(hybridData: HybridData) {
54
+ mHybridData = hybridData
55
+ }
56
+
57
+ @DoNotStrip
58
+ @Keep
59
+ override fun invoke(status: PermissionStatus): Unit
60
+ = invoke_cxx(status)
61
+
62
+ @FastNative
63
+ private external fun invoke_cxx(status: PermissionStatus): Unit
64
+ }
65
+
66
+ /**
67
+ * Represents the JavaScript callback `(status: enum) => void`.
68
+ * This is implemented in Java/Kotlin, via a `(PermissionStatus) -> Unit`.
69
+ * The callback is always coming from native.
70
+ */
71
+ @DoNotStrip
72
+ @Keep
73
+ @Suppress("ClassName", "RedundantUnitReturnType", "unused")
74
+ class Func_void_PermissionStatus_java(private val function: (PermissionStatus) -> Unit): Func_void_PermissionStatus {
75
+ @DoNotStrip
76
+ @Keep
77
+ override fun invoke(status: PermissionStatus): Unit {
78
+ return this.function(status)
79
+ }
80
+ }
@@ -209,6 +209,15 @@ abstract class HybridNitroLocationTrackingSpec: HybridObject() {
209
209
  @Keep
210
210
  abstract fun requestLocationPermission(): Promise<PermissionStatus>
211
211
 
212
+ abstract fun onPermissionStatusChange(callback: (status: PermissionStatus) -> Unit): Unit
213
+
214
+ @DoNotStrip
215
+ @Keep
216
+ private fun onPermissionStatusChange_cxx(callback: Func_void_PermissionStatus): Unit {
217
+ val __result = onPermissionStatusChange(callback)
218
+ return __result
219
+ }
220
+
212
221
  @DoNotStrip
213
222
  @Keep
214
223
  abstract fun getDistanceBetween(lat1: Double, lon1: Double, lat2: Double, lon2: Double): Double
@@ -23,6 +23,7 @@
23
23
  #include "JFunc_void_GeofenceEvent_std__string.hpp"
24
24
  #include "JFunc_void_SpeedAlertType_double.hpp"
25
25
  #include "JFunc_void_LocationProviderStatus_LocationProviderStatus.hpp"
26
+ #include "JFunc_void_PermissionStatus.hpp"
26
27
  #include <NitroModules/DefaultConstructableObject.hpp>
27
28
 
28
29
  namespace margelo::nitro::nitrolocationtracking {
@@ -42,6 +43,7 @@ int initialize(JavaVM* vm) {
42
43
  margelo::nitro::nitrolocationtracking::JFunc_void_GeofenceEvent_std__string_cxx::registerNatives();
43
44
  margelo::nitro::nitrolocationtracking::JFunc_void_SpeedAlertType_double_cxx::registerNatives();
44
45
  margelo::nitro::nitrolocationtracking::JFunc_void_LocationProviderStatus_LocationProviderStatus_cxx::registerNatives();
46
+ margelo::nitro::nitrolocationtracking::JFunc_void_PermissionStatus_cxx::registerNatives();
45
47
 
46
48
  // Register Nitro Hybrid Objects
47
49
  HybridObjectRegistry::registerHybridObjectConstructor(
@@ -318,6 +318,12 @@ namespace margelo::nitro::nitrolocationtracking {
318
318
  auto __value = std::move(__result.value());
319
319
  return __value;
320
320
  }
321
+ inline void onPermissionStatusChange(const std::function<void(PermissionStatus /* status */)>& callback) override {
322
+ auto __result = _swiftPart.onPermissionStatusChange(callback);
323
+ if (__result.hasError()) [[unlikely]] {
324
+ std::rethrow_exception(__result.error());
325
+ }
326
+ }
321
327
  inline double getDistanceBetween(double lat1, double lon1, double lat2, double lon2) override {
322
328
  auto __result = _swiftPart.getDistanceBetween(std::forward<decltype(lat1)>(lat1), std::forward<decltype(lon1)>(lon1), std::forward<decltype(lat2)>(lat2), std::forward<decltype(lon2)>(lon2));
323
329
  if (__result.hasError()) [[unlikely]] {
@@ -45,6 +45,7 @@ public protocol HybridNitroLocationTrackingSpec_protocol: HybridObject {
45
45
  func onProviderStatusChange(callback: @escaping (_ gps: LocationProviderStatus, _ network: LocationProviderStatus) -> Void) throws -> Void
46
46
  func getLocationPermissionStatus() throws -> PermissionStatus
47
47
  func requestLocationPermission() throws -> Promise<PermissionStatus>
48
+ func onPermissionStatusChange(callback: @escaping (_ status: PermissionStatus) -> Void) throws -> Void
48
49
  func getDistanceBetween(lat1: Double, lon1: Double, lat2: Double, lon2: Double) throws -> Double
49
50
  func getDistanceToGeofence(regionId: String) throws -> Double
50
51
  func showLocalNotification(title: String, body: String) throws -> Void
@@ -543,6 +543,22 @@ open class HybridNitroLocationTrackingSpec_cxx {
543
543
  }
544
544
  }
545
545
 
546
+ @inline(__always)
547
+ public final func onPermissionStatusChange(callback: bridge.Func_void_PermissionStatus) -> bridge.Result_void_ {
548
+ do {
549
+ try self.__implementation.onPermissionStatusChange(callback: { () -> (PermissionStatus) -> Void in
550
+ let __wrappedFunction = bridge.wrap_Func_void_PermissionStatus(callback)
551
+ return { (__status: PermissionStatus) -> Void in
552
+ __wrappedFunction.call(__status.rawValue)
553
+ }
554
+ }())
555
+ return bridge.create_Result_void_()
556
+ } catch (let __error) {
557
+ let __exceptionPtr = __error.toCpp()
558
+ return bridge.create_Result_void_(__exceptionPtr)
559
+ }
560
+ }
561
+
546
562
  @inline(__always)
547
563
  public final func getDistanceBetween(lat1: Double, lon1: Double, lat2: Double, lon2: Double) -> bridge.Result_double_ {
548
564
  do {
@@ -46,6 +46,7 @@ namespace margelo::nitro::nitrolocationtracking {
46
46
  prototype.registerHybridMethod("onProviderStatusChange", &HybridNitroLocationTrackingSpec::onProviderStatusChange);
47
47
  prototype.registerHybridMethod("getLocationPermissionStatus", &HybridNitroLocationTrackingSpec::getLocationPermissionStatus);
48
48
  prototype.registerHybridMethod("requestLocationPermission", &HybridNitroLocationTrackingSpec::requestLocationPermission);
49
+ prototype.registerHybridMethod("onPermissionStatusChange", &HybridNitroLocationTrackingSpec::onPermissionStatusChange);
49
50
  prototype.registerHybridMethod("getDistanceBetween", &HybridNitroLocationTrackingSpec::getDistanceBetween);
50
51
  prototype.registerHybridMethod("getDistanceToGeofence", &HybridNitroLocationTrackingSpec::getDistanceToGeofence);
51
52
  prototype.registerHybridMethod("showLocalNotification", &HybridNitroLocationTrackingSpec::showLocalNotification);
@@ -114,6 +114,7 @@ namespace margelo::nitro::nitrolocationtracking {
114
114
  virtual void onProviderStatusChange(const std::function<void(LocationProviderStatus /* gps */, LocationProviderStatus /* network */)>& callback) = 0;
115
115
  virtual PermissionStatus getLocationPermissionStatus() = 0;
116
116
  virtual std::shared_ptr<Promise<PermissionStatus>> requestLocationPermission() = 0;
117
+ virtual void onPermissionStatusChange(const std::function<void(PermissionStatus /* status */)>& callback) = 0;
117
118
  virtual double getDistanceBetween(double lat1, double lon1, double lat2, double lon2) = 0;
118
119
  virtual double getDistanceToGeofence(const std::string& regionId) = 0;
119
120
  virtual void showLocalNotification(const std::string& title, const std::string& body) = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nitro-location-tracking",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "A React Native Nitro module for location tracking",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -89,6 +89,8 @@ export type PermissionStatus =
89
89
  | 'whenInUse'
90
90
  | 'always';
91
91
 
92
+ export type PermissionStatusCallback = (status: PermissionStatus) => void;
93
+
92
94
  // ─── Hybrid Object ──────────────────────────────────
93
95
 
94
96
  export interface NitroLocationTracking
@@ -144,6 +146,7 @@ export interface NitroLocationTracking
144
146
  // === Permission Status ===
145
147
  getLocationPermissionStatus(): PermissionStatus;
146
148
  requestLocationPermission(): Promise<PermissionStatus>;
149
+ onPermissionStatusChange(callback: PermissionStatusCallback): void;
147
150
 
148
151
  // === Distance Utilities ===
149
152
  getDistanceBetween(
package/src/index.tsx CHANGED
@@ -32,6 +32,7 @@ export type {
32
32
  LocationProviderStatus,
33
33
  ProviderStatusCallback,
34
34
  PermissionStatus,
35
+ PermissionStatusCallback,
35
36
  } from './NitroLocationTracking.nitro';
36
37
 
37
38
  export function useDriverLocation(config: LocationConfig) {