react-native-nitro-location-tracking 0.1.12 → 0.1.14
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 +52 -0
- package/android/CMakeLists.txt +4 -1
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/AirplaneModeMonitor.kt +72 -0
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/LocationEngine.kt +30 -9
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/NitroLocationTracking.kt +173 -1
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/PermissionStatusMonitor.kt +26 -0
- package/cpp/HybridNitroLocationComplexLogicsCalculation.cpp +204 -0
- package/cpp/HybridNitroLocationComplexLogicsCalculation.hpp +29 -0
- package/ios/LocationEngine.swift +11 -0
- package/ios/NitroLocationTracking.swift +68 -0
- package/lib/module/NitroLocationComplexLogicsCalculation.nitro.js +4 -0
- package/lib/module/NitroLocationComplexLogicsCalculation.nitro.js.map +1 -0
- package/lib/module/index.js +1 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NitroLocationComplexLogicsCalculation.nitro.d.ts +25 -0
- package/lib/typescript/src/NitroLocationComplexLogicsCalculation.nitro.d.ts.map +1 -0
- package/lib/typescript/src/NitroLocationTracking.nitro.d.ts +17 -0
- package/lib/typescript/src/NitroLocationTracking.nitro.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridNitroLocationTrackingSpec.cpp +25 -0
- package/nitrogen/generated/android/c++/JHybridNitroLocationTrackingSpec.hpp +3 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/HybridNitroLocationTrackingSpec.kt +17 -0
- package/nitrogen/generated/android/nitrolocationtracking+autolinking.cmake +1 -0
- package/nitrogen/generated/ios/c++/HybridNitroLocationTrackingSpecSwift.hpp +22 -0
- package/nitrogen/generated/ios/swift/HybridNitroLocationTrackingSpec.swift +3 -0
- package/nitrogen/generated/ios/swift/HybridNitroLocationTrackingSpec_cxx.swift +47 -0
- package/nitrogen/generated/shared/c++/HybridNitroLocationComplexLogicsCalculationSpec.cpp +25 -0
- package/nitrogen/generated/shared/c++/HybridNitroLocationComplexLogicsCalculationSpec.hpp +72 -0
- package/nitrogen/generated/shared/c++/HybridNitroLocationTrackingSpec.cpp +3 -0
- package/nitrogen/generated/shared/c++/HybridNitroLocationTrackingSpec.hpp +3 -0
- package/nitrogen/generated/shared/c++/LocationPoint.hpp +99 -0
- package/nitrogen/generated/shared/c++/TripMathStats.hpp +95 -0
- package/package.json +1 -1
- package/src/NitroLocationComplexLogicsCalculation.nitro.ts +37 -0
- package/src/NitroLocationTracking.nitro.ts +19 -0
- package/src/index.tsx +10 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
#include "HybridNitroLocationComplexLogicsCalculation.hpp"
|
|
2
|
+
#include <cmath>
|
|
3
|
+
#include <algorithm>
|
|
4
|
+
|
|
5
|
+
namespace margelo::nitro::nitrolocationtracking {
|
|
6
|
+
|
|
7
|
+
// Mathematical constants
|
|
8
|
+
constexpr double PI = 3.14159265358979323846;
|
|
9
|
+
constexpr double EARTH_RADIUS_M = 6371000.0;
|
|
10
|
+
|
|
11
|
+
double HybridNitroLocationComplexLogicsCalculation::haversineDistance(double lat1, double lon1, double lat2, double lon2) {
|
|
12
|
+
double p = PI / 180.0;
|
|
13
|
+
double a = 0.5 - std::cos((lat2 - lat1) * p)/2.0 +
|
|
14
|
+
std::cos(lat1 * p) * std::cos(lat2 * p) *
|
|
15
|
+
(1.0 - std::cos((lon2 - lon1) * p))/2.0;
|
|
16
|
+
|
|
17
|
+
return 2.0 * EARTH_RADIUS_M * std::asin(std::sqrt(a));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
TripMathStats HybridNitroLocationComplexLogicsCalculation::calculateTotalTripStats(const std::vector<LocationPoint>& points) {
|
|
21
|
+
TripMathStats stats = {0.0, 0.0, 0.0, 0.0};
|
|
22
|
+
|
|
23
|
+
if (points.size() < 2) return stats;
|
|
24
|
+
|
|
25
|
+
double totalDist = 0.0;
|
|
26
|
+
double maxSpeed = 0.0;
|
|
27
|
+
double totalTimeMs = points.back().timestamp - points.front().timestamp;
|
|
28
|
+
|
|
29
|
+
for (size_t i = 1; i < points.size(); ++i) {
|
|
30
|
+
const auto& p1 = points[i-1];
|
|
31
|
+
const auto& p2 = points[i];
|
|
32
|
+
|
|
33
|
+
double dist = haversineDistance(p1.latitude, p1.longitude, p2.latitude, p2.longitude);
|
|
34
|
+
totalDist += dist;
|
|
35
|
+
|
|
36
|
+
if (p2.speed > maxSpeed) {
|
|
37
|
+
maxSpeed = p2.speed;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
stats.totalDistanceMeters = totalDist;
|
|
42
|
+
stats.elapsedTimeMs = totalTimeMs;
|
|
43
|
+
|
|
44
|
+
// Convert max speed m/s to km/h if it comes in m/s, assume it's m/s
|
|
45
|
+
stats.maxSpeedKmh = maxSpeed * 3.6;
|
|
46
|
+
|
|
47
|
+
if (totalTimeMs > 0) {
|
|
48
|
+
double avgSpeedMps = totalDist / (totalTimeMs / 1000.0);
|
|
49
|
+
stats.averageSpeedKmh = avgSpeedMps * 3.6;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return stats;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
std::vector<LocationPoint> HybridNitroLocationComplexLogicsCalculation::filterAnomalousPoints(const std::vector<LocationPoint>& points, double maxSpeedLimitMs) {
|
|
56
|
+
std::vector<LocationPoint> filtered;
|
|
57
|
+
if (points.empty()) return filtered;
|
|
58
|
+
|
|
59
|
+
filtered.push_back(points.front());
|
|
60
|
+
|
|
61
|
+
for (size_t i = 1; i < points.size(); ++i) {
|
|
62
|
+
const auto& curr = points[i];
|
|
63
|
+
const auto& last = filtered.back();
|
|
64
|
+
|
|
65
|
+
double dist = haversineDistance(last.latitude, last.longitude, curr.latitude, curr.longitude);
|
|
66
|
+
double timeDiffSec = (curr.timestamp - last.timestamp) / 1000.0;
|
|
67
|
+
|
|
68
|
+
if (timeDiffSec <= 0) continue; // Invalid time
|
|
69
|
+
|
|
70
|
+
double calcSpeed = dist / timeDiffSec;
|
|
71
|
+
|
|
72
|
+
// If the calculated speed is ridiculously high (teleportation), ignore point
|
|
73
|
+
if (calcSpeed <= maxSpeedLimitMs) {
|
|
74
|
+
filtered.push_back(curr);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return filtered;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
double HybridNitroLocationComplexLogicsCalculation::perpendicularDistance(const LocationPoint& pt, const LocationPoint& lineStart, const LocationPoint& lineEnd) {
|
|
82
|
+
double dx = lineEnd.longitude - lineStart.longitude;
|
|
83
|
+
double dy = lineEnd.latitude - lineStart.latitude;
|
|
84
|
+
|
|
85
|
+
double mag = std::sqrt(dx*dx + dy*dy);
|
|
86
|
+
if (mag > 0.0) {
|
|
87
|
+
dx /= mag;
|
|
88
|
+
dy /= mag;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
double pvx = pt.longitude - lineStart.longitude;
|
|
92
|
+
double pvy = pt.latitude - lineStart.latitude;
|
|
93
|
+
|
|
94
|
+
double pvdot = dx * pvx + dy * pvy;
|
|
95
|
+
|
|
96
|
+
double ax = pvx - pvdot * dx;
|
|
97
|
+
double ay = pvy - pvdot * dy;
|
|
98
|
+
|
|
99
|
+
// Calculate distance in coordinates and roughly convert to meters using Haversine
|
|
100
|
+
double projLat = pt.latitude - ay;
|
|
101
|
+
double projLon = pt.longitude - ax;
|
|
102
|
+
return haversineDistance(pt.latitude, pt.longitude, projLat, projLon);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
void HybridNitroLocationComplexLogicsCalculation::douglasPeucker(const std::vector<LocationPoint>& points, double tolerance, int firstIdx, int lastIdx, std::vector<int>& keepIndexes) {
|
|
106
|
+
if (lastIdx <= firstIdx + 1) return;
|
|
107
|
+
|
|
108
|
+
double maxDist = 0.0;
|
|
109
|
+
int index = firstIdx;
|
|
110
|
+
|
|
111
|
+
for (int i = firstIdx + 1; i < lastIdx; ++i) {
|
|
112
|
+
double dist = perpendicularDistance(points[i], points[firstIdx], points[lastIdx]);
|
|
113
|
+
if (dist > maxDist) {
|
|
114
|
+
index = i;
|
|
115
|
+
maxDist = dist;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (maxDist > tolerance) {
|
|
120
|
+
keepIndexes.push_back(index);
|
|
121
|
+
douglasPeucker(points, tolerance, firstIdx, index, keepIndexes);
|
|
122
|
+
douglasPeucker(points, tolerance, index, lastIdx, keepIndexes);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
std::vector<LocationPoint> HybridNitroLocationComplexLogicsCalculation::smoothPath(const std::vector<LocationPoint>& points, double toleranceMeters) {
|
|
127
|
+
if (points.size() < 3) return points;
|
|
128
|
+
|
|
129
|
+
std::vector<int> keepIndexes;
|
|
130
|
+
keepIndexes.push_back(0);
|
|
131
|
+
keepIndexes.push_back(points.size() - 1);
|
|
132
|
+
|
|
133
|
+
douglasPeucker(points, toleranceMeters, 0, points.size() - 1, keepIndexes);
|
|
134
|
+
|
|
135
|
+
std::sort(keepIndexes.begin(), keepIndexes.end());
|
|
136
|
+
|
|
137
|
+
std::vector<LocationPoint> smoothed;
|
|
138
|
+
for (int idx : keepIndexes) {
|
|
139
|
+
smoothed.push_back(points[idx]);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return smoothed;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
double HybridNitroLocationComplexLogicsCalculation::calculateBearing(double lat1, double lon1, double lat2, double lon2) {
|
|
146
|
+
double p = PI / 180.0;
|
|
147
|
+
double dLon = (lon2 - lon1) * p;
|
|
148
|
+
double rLat1 = lat1 * p;
|
|
149
|
+
double rLat2 = lat2 * p;
|
|
150
|
+
|
|
151
|
+
double y = std::sin(dLon) * std::cos(rLat2);
|
|
152
|
+
double x = std::cos(rLat1) * std::sin(rLat2) -
|
|
153
|
+
std::sin(rLat1) * std::cos(rLat2) * std::cos(dLon);
|
|
154
|
+
|
|
155
|
+
double bearing = std::atan2(y, x) * (180.0 / PI);
|
|
156
|
+
return std::fmod((bearing + 360.0), 360.0);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
std::string HybridNitroLocationComplexLogicsCalculation::encodeGeohash(double latitude, double longitude, double precisionRaw) {
|
|
160
|
+
static const char BASE32[] = "0123456789bcdefghjkmnpqrstuvwxyz";
|
|
161
|
+
|
|
162
|
+
int precision = static_cast<int>(precisionRaw);
|
|
163
|
+
if (precision < 1) precision = 1;
|
|
164
|
+
if (precision > 12) precision = 12;
|
|
165
|
+
|
|
166
|
+
bool is_even = true;
|
|
167
|
+
double lat[2] = {-90.0, 90.0};
|
|
168
|
+
double lon[2] = {-180.0, 180.0};
|
|
169
|
+
int bit = 0;
|
|
170
|
+
int ch = 0;
|
|
171
|
+
std::string geohash = "";
|
|
172
|
+
|
|
173
|
+
while (geohash.length() < precision) {
|
|
174
|
+
if (is_even) {
|
|
175
|
+
double mid = (lon[0] + lon[1]) / 2;
|
|
176
|
+
if (longitude > mid) {
|
|
177
|
+
ch |= (1 << (4 - bit));
|
|
178
|
+
lon[0] = mid;
|
|
179
|
+
} else {
|
|
180
|
+
lon[1] = mid;
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
double mid = (lat[0] + lat[1]) / 2;
|
|
184
|
+
if (latitude > mid) {
|
|
185
|
+
ch |= (1 << (4 - bit));
|
|
186
|
+
lat[0] = mid;
|
|
187
|
+
} else {
|
|
188
|
+
lat[1] = mid;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
is_even = !is_even;
|
|
193
|
+
if (bit < 4) {
|
|
194
|
+
bit++;
|
|
195
|
+
} else {
|
|
196
|
+
geohash += BASE32[ch];
|
|
197
|
+
bit = 0;
|
|
198
|
+
ch = 0;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return geohash;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
} // namespace margelo::nitro::nitrolocationtracking
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "HybridNitroLocationComplexLogicsCalculationSpec.hpp"
|
|
4
|
+
#include <vector>
|
|
5
|
+
|
|
6
|
+
namespace margelo::nitro::nitrolocationtracking {
|
|
7
|
+
|
|
8
|
+
class HybridNitroLocationComplexLogicsCalculation : public HybridNitroLocationComplexLogicsCalculationSpec {
|
|
9
|
+
public:
|
|
10
|
+
HybridNitroLocationComplexLogicsCalculation() : HybridObject(TAG) {}
|
|
11
|
+
|
|
12
|
+
// Methods
|
|
13
|
+
TripMathStats calculateTotalTripStats(const std::vector<LocationPoint>& points) override;
|
|
14
|
+
|
|
15
|
+
std::vector<LocationPoint> filterAnomalousPoints(const std::vector<LocationPoint>& points, double maxSpeedLimitMs) override;
|
|
16
|
+
|
|
17
|
+
std::vector<LocationPoint> smoothPath(const std::vector<LocationPoint>& points, double toleranceMeters) override;
|
|
18
|
+
|
|
19
|
+
double calculateBearing(double lat1, double lon1, double lat2, double lon2) override;
|
|
20
|
+
|
|
21
|
+
std::string encodeGeohash(double latitude, double longitude, double precision) override;
|
|
22
|
+
|
|
23
|
+
private:
|
|
24
|
+
double haversineDistance(double lat1, double lon1, double lat2, double lon2);
|
|
25
|
+
double perpendicularDistance(const LocationPoint& pt, const LocationPoint& lineStart, const LocationPoint& lineEnd);
|
|
26
|
+
void douglasPeucker(const std::vector<LocationPoint>& points, double tolerance, int firstIdx, int lastIdx, std::vector<int>& keepIndexes);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
} // namespace margelo::nitro::nitrolocationtracking
|
package/ios/LocationEngine.swift
CHANGED
|
@@ -238,6 +238,17 @@ class LocationEngine: NSObject, CLLocationManagerDelegate {
|
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
+
// Auto-stop if permission was revoked while tracking. Without this the
|
|
242
|
+
// engine stays flagged as tracking but Core Location silently delivers
|
|
243
|
+
// nothing, leaving the app in an inconsistent state.
|
|
244
|
+
if authStatus == .denied || authStatus == .restricted {
|
|
245
|
+
if tracking {
|
|
246
|
+
locationManager.stopUpdatingLocation()
|
|
247
|
+
tracking = false
|
|
248
|
+
pendingStartAfterPermission = false
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
241
252
|
// Notify JS about permission status change (deduplicated)
|
|
242
253
|
let permStatus = Self.mapAuthStatus(authStatus)
|
|
243
254
|
if permStatus != lastPermissionStatus {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import CoreLocation
|
|
3
3
|
import NitroModules
|
|
4
|
+
import UIKit
|
|
4
5
|
|
|
5
6
|
class NitroLocationTracking: HybridNitroLocationTrackingSpec {
|
|
6
7
|
private let locationEngine = LocationEngine()
|
|
@@ -249,6 +250,73 @@ class NitroLocationTracking: HybridNitroLocationTrackingSpec {
|
|
|
249
250
|
locationEngine.permissionStatusCallback = callback
|
|
250
251
|
}
|
|
251
252
|
|
|
253
|
+
func openLocationSettings() throws -> Promise<Bool> {
|
|
254
|
+
let promise = Promise<Bool>()
|
|
255
|
+
|
|
256
|
+
// Guard against double-resolve — didBecomeActive can fire more than
|
|
257
|
+
// once while the user bounces between apps, and we also resolve from
|
|
258
|
+
// the open(url) completion handler on failure.
|
|
259
|
+
let resolvedLock = NSLock()
|
|
260
|
+
var hasResolved = false
|
|
261
|
+
func safeResolve(_ value: Bool) {
|
|
262
|
+
resolvedLock.lock()
|
|
263
|
+
defer { resolvedLock.unlock() }
|
|
264
|
+
if hasResolved { return }
|
|
265
|
+
hasResolved = true
|
|
266
|
+
promise.resolve(withResult: value)
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
DispatchQueue.main.async {
|
|
270
|
+
guard let url = URL(string: UIApplication.openSettingsURLString),
|
|
271
|
+
UIApplication.shared.canOpenURL(url) else {
|
|
272
|
+
safeResolve(CLLocationManager.locationServicesEnabled())
|
|
273
|
+
return
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Register the observer BEFORE opening Settings so we never miss
|
|
277
|
+
// the return-to-foreground event.
|
|
278
|
+
var observer: NSObjectProtocol?
|
|
279
|
+
observer = NotificationCenter.default.addObserver(
|
|
280
|
+
forName: UIApplication.didBecomeActiveNotification,
|
|
281
|
+
object: nil,
|
|
282
|
+
queue: .main
|
|
283
|
+
) { _ in
|
|
284
|
+
if let obs = observer {
|
|
285
|
+
NotificationCenter.default.removeObserver(obs)
|
|
286
|
+
observer = nil
|
|
287
|
+
}
|
|
288
|
+
// Give iOS a short beat to refresh the location-services flag
|
|
289
|
+
// after the user toggles it in Settings.
|
|
290
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
|
291
|
+
safeResolve(CLLocationManager.locationServicesEnabled())
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
UIApplication.shared.open(url, options: [:]) { success in
|
|
296
|
+
if !success {
|
|
297
|
+
if let obs = observer {
|
|
298
|
+
NotificationCenter.default.removeObserver(obs)
|
|
299
|
+
observer = nil
|
|
300
|
+
}
|
|
301
|
+
safeResolve(CLLocationManager.locationServicesEnabled())
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return promise
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// MARK: - Device State Monitoring
|
|
310
|
+
|
|
311
|
+
func isAirplaneModeEnabled() throws -> Bool {
|
|
312
|
+
// iOS does not provide a public API for Airplane Mode detection
|
|
313
|
+
return false
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
func onAirplaneModeChange(callback: @escaping (Bool) -> Void) throws {
|
|
317
|
+
// iOS does not provide public broadcasts for Airplane Mode changes
|
|
318
|
+
}
|
|
319
|
+
|
|
252
320
|
// MARK: - Distance Utilities
|
|
253
321
|
|
|
254
322
|
func getDistanceBetween(lat1: Double, lon1: Double, lat2: Double, lon2: Double) throws -> Double {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["NitroLocationComplexLogicsCalculation.nitro.ts"],"mappings":"","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
import { useState, useEffect, useCallback, useRef } from 'react';
|
|
4
4
|
import { NitroModules } from 'react-native-nitro-modules';
|
|
5
5
|
const NitroLocationModule = NitroModules.createHybridObject('NitroLocationTracking');
|
|
6
|
+
export const NitroLocationCalculations = NitroModules.createHybridObject('NitroLocationComplexLogicsCalculation');
|
|
6
7
|
export default NitroLocationModule;
|
|
7
8
|
export { requestLocationPermission } from "./requestPermission.js";
|
|
8
9
|
export { LocationSmoother } from "./LocationSmoother.js";
|
|
9
10
|
export { shortestRotation, calculateBearing } from "./bearing.js";
|
|
10
|
-
// export * from './db'
|
|
11
|
-
|
|
12
11
|
export function useDriverLocation(config) {
|
|
13
12
|
const [location, setLocation] = useState(null);
|
|
14
13
|
const [isMoving, setIsMoving] = useState(false);
|
package/lib/module/index.js.map
CHANGED
|
@@ -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,
|
|
1
|
+
{"version":3,"names":["useState","useEffect","useCallback","useRef","NitroModules","NitroLocationModule","createHybridObject","NitroLocationCalculations","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,OAAO,MAAMC,yBAAyB,GAAGH,YAAY,CAACE,kBAAkB,CAEtE,uCAAuC,CAAC;AAE1C,eAAeD,mBAAmB;AAClC,SAASG,yBAAyB,QAAQ,wBAAqB;AAC/D,SAASC,gBAAgB,QAAQ,uBAAoB;AACrD,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,cAAW;AA0B9D,OAAO,SAASC,iBAAiBA,CAACC,MAAsB,EAAE;EACxD,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGf,QAAQ,CAAsB,IAAI,CAAC;EACnE,MAAM,CAACgB,QAAQ,EAAEC,WAAW,CAAC,GAAGjB,QAAQ,CAAC,KAAK,CAAC;EAC/C,MAAM,CAACkB,UAAU,EAAEC,aAAa,CAAC,GAAG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AS,CAAC,MAAM;IACdI,mBAAmB,CAACgC,mBAAmB,CAACxB,MAAM,CAAC;IAC/CR,mBAAmB,CAACiC,uBAAuB,CAACJ,kBAAkB,CAAC;IAC/D7B,mBAAmB,CAACkC,SAAS,CAACH,cAAc,CAAC;IAC7C,OAAO,MAAM;MACX/B,mBAAmB,CAACmC,mBAAmB,CAAC,CAAC;IAC3C,CAAC;EACH,CAAC,EAAE,CAAC3B,MAAM,CAAC,CAAC;EAEZ,OAAO;IACLoB,eAAe;IACfE,WAAW;IACXM,OAAO,EAAEvC,WAAW,CAAC,MAAMG,mBAAmB,CAACqC,gBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC;IACtEC,UAAU,EAAEzC,WAAW,CACrB,MAAMG,mBAAmB,CAACmC,mBAAmB,CAAC,CAAC,EAC/C,EACF,CAAC;IACDI,IAAI,EAAE1C,WAAW,CAAE2C,CAAS,IAAKxC,mBAAmB,CAACyC,WAAW,CAACD,CAAC,CAAC,EAAE,EAAE;EACzE,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
export interface LocationPoint {
|
|
3
|
+
latitude: number;
|
|
4
|
+
longitude: number;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
speed: number;
|
|
7
|
+
accuracy: number;
|
|
8
|
+
}
|
|
9
|
+
export interface TripMathStats {
|
|
10
|
+
totalDistanceMeters: number;
|
|
11
|
+
elapsedTimeMs: number;
|
|
12
|
+
maxSpeedKmh: number;
|
|
13
|
+
averageSpeedKmh: number;
|
|
14
|
+
}
|
|
15
|
+
export interface NitroLocationComplexLogicsCalculation extends HybridObject<{
|
|
16
|
+
ios: 'c++';
|
|
17
|
+
android: 'c++';
|
|
18
|
+
}> {
|
|
19
|
+
calculateTotalTripStats(points: LocationPoint[]): TripMathStats;
|
|
20
|
+
filterAnomalousPoints(points: LocationPoint[], maxSpeedLimitMs: number): LocationPoint[];
|
|
21
|
+
smoothPath(points: LocationPoint[], toleranceMeters: number): LocationPoint[];
|
|
22
|
+
calculateBearing(lat1: number, lon1: number, lat2: number, lon2: number): number;
|
|
23
|
+
encodeGeohash(latitude: number, longitude: number, precision: number): string;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=NitroLocationComplexLogicsCalculation.nitro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NitroLocationComplexLogicsCalculation.nitro.d.ts","sourceRoot":"","sources":["../../../src/NitroLocationComplexLogicsCalculation.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,qCACf,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;IACpD,uBAAuB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC;IAEhE,qBAAqB,CACnB,MAAM,EAAE,aAAa,EAAE,EACvB,eAAe,EAAE,MAAM,GACtB,aAAa,EAAE,CAAC;IAEnB,UAAU,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,eAAe,EAAE,MAAM,GAAG,aAAa,EAAE,CAAC;IAE9E,gBAAgB,CACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,MAAM,CAAC;IAEV,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;CAC/E"}
|
|
@@ -101,6 +101,23 @@ export interface NitroLocationTracking extends HybridObject<{
|
|
|
101
101
|
getLocationPermissionStatus(): PermissionStatus;
|
|
102
102
|
requestLocationPermission(): Promise<PermissionStatus>;
|
|
103
103
|
onPermissionStatusChange(callback: PermissionStatusCallback): void;
|
|
104
|
+
/**
|
|
105
|
+
* Prompt the user to enable device location (GPS).
|
|
106
|
+
*
|
|
107
|
+
* On Android this shows the native Google Play Services in-app resolution
|
|
108
|
+
* dialog ("For better experience, turn on device location…"). The promise
|
|
109
|
+
* resolves `true` if GPS is enabled (either because it already was, or
|
|
110
|
+
* because the user accepted the dialog), and `false` if the user declined
|
|
111
|
+
* or the dialog could not be shown.
|
|
112
|
+
*
|
|
113
|
+
* On iOS there is no in-app dialog for enabling location services, so this
|
|
114
|
+
* opens the app's Settings page. The promise resolves after the app
|
|
115
|
+
* returns to foreground: `true` if `locationServicesEnabled()` is now on,
|
|
116
|
+
* `false` otherwise.
|
|
117
|
+
*/
|
|
118
|
+
openLocationSettings(): Promise<boolean>;
|
|
119
|
+
isAirplaneModeEnabled(): boolean;
|
|
120
|
+
onAirplaneModeChange(callback: (isEnabled: boolean) => void): void;
|
|
104
121
|
getDistanceBetween(lat1: number, lon1: number, lat2: number, lon2: number): number;
|
|
105
122
|
getDistanceToGeofence(regionId: string): number;
|
|
106
123
|
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,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI/D,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,C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GAAG,IAAI,CAAC;IAG/D,2BAA2B,IAAI,gBAAgB,CAAC;IAChD,yBAAyB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACvD,wBAAwB,CAAC,QAAQ,EAAE,wBAAwB,GAAG,IAAI,CAAC;IACnE;;;;;;;;;;;;;OAaG;IACH,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAGzC,qBAAqB,IAAI,OAAO,CAAC;IACjC,oBAAoB,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAAC;IAGnE,kBAAkB,CAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,MAAM,CAAC;IACV,qBAAqB,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"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { NitroLocationTracking, LocationData, LocationConfig, ConnectionConfig } from './NitroLocationTracking.nitro';
|
|
2
2
|
declare const NitroLocationModule: NitroLocationTracking;
|
|
3
|
+
export declare const NitroLocationCalculations: import("./NitroLocationComplexLogicsCalculation.nitro").NitroLocationComplexLogicsCalculation;
|
|
3
4
|
export default NitroLocationModule;
|
|
4
5
|
export { requestLocationPermission } from './requestPermission';
|
|
5
6
|
export { LocationSmoother } from './LocationSmoother';
|
|
6
7
|
export { shortestRotation, calculateBearing } from './bearing';
|
|
7
8
|
export type { NitroLocationTracking, LocationData, LocationConfig, ConnectionConfig, GeofenceRegion, GeofenceEvent, GeofenceCallback, SpeedConfig, SpeedAlertType, SpeedAlertCallback, TripStats, LocationProviderStatus, ProviderStatusCallback, PermissionStatus, PermissionStatusCallback, MockLocationCallback, } from './NitroLocationTracking.nitro';
|
|
9
|
+
export type { NitroLocationComplexLogicsCalculation, LocationPoint, TripMathStats, } from './NitroLocationComplexLogicsCalculation.nitro';
|
|
8
10
|
export declare function useDriverLocation(config: LocationConfig): {
|
|
9
11
|
location: LocationData | null;
|
|
10
12
|
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;
|
|
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,eAAO,MAAM,yBAAyB,+FAEI,CAAC;AAE3C,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;AAC/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,EACxB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AAEvC,YAAY,EACV,qCAAqC,EACrC,aAAa,EACb,aAAa,GACd,MAAM,+CAA+C,CAAC;AAEvD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc;;;;;;EAuCvD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB;;;;;cAuBhC,MAAM;EAE/B"}
|
|
@@ -290,6 +290,31 @@ namespace margelo::nitro::nitrolocationtracking {
|
|
|
290
290
|
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_PermissionStatus::javaobject> /* callback */)>("onPermissionStatusChange_cxx");
|
|
291
291
|
method(_javaPart, JFunc_void_PermissionStatus_cxx::fromCpp(callback));
|
|
292
292
|
}
|
|
293
|
+
std::shared_ptr<Promise<bool>> JHybridNitroLocationTrackingSpec::openLocationSettings() {
|
|
294
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("openLocationSettings");
|
|
295
|
+
auto __result = method(_javaPart);
|
|
296
|
+
return [&]() {
|
|
297
|
+
auto __promise = Promise<bool>::create();
|
|
298
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
299
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
300
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
301
|
+
});
|
|
302
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
303
|
+
jni::JniException __jniError(__throwable);
|
|
304
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
305
|
+
});
|
|
306
|
+
return __promise;
|
|
307
|
+
}();
|
|
308
|
+
}
|
|
309
|
+
bool JHybridNitroLocationTrackingSpec::isAirplaneModeEnabled() {
|
|
310
|
+
static const auto method = javaClassStatic()->getMethod<jboolean()>("isAirplaneModeEnabled");
|
|
311
|
+
auto __result = method(_javaPart);
|
|
312
|
+
return static_cast<bool>(__result);
|
|
313
|
+
}
|
|
314
|
+
void JHybridNitroLocationTrackingSpec::onAirplaneModeChange(const std::function<void(bool /* isEnabled */)>& callback) {
|
|
315
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_bool::javaobject> /* callback */)>("onAirplaneModeChange_cxx");
|
|
316
|
+
method(_javaPart, JFunc_void_bool_cxx::fromCpp(callback));
|
|
317
|
+
}
|
|
293
318
|
double JHybridNitroLocationTrackingSpec::getDistanceBetween(double lat1, double lon1, double lat2, double lon2) {
|
|
294
319
|
static const auto method = javaClassStatic()->getMethod<double(double /* lat1 */, double /* lon1 */, double /* lat2 */, double /* lon2 */)>("getDistanceBetween");
|
|
295
320
|
auto __result = method(_javaPart, lat1, lon1, lat2, lon2);
|
|
@@ -89,6 +89,9 @@ namespace margelo::nitro::nitrolocationtracking {
|
|
|
89
89
|
PermissionStatus getLocationPermissionStatus() override;
|
|
90
90
|
std::shared_ptr<Promise<PermissionStatus>> requestLocationPermission() override;
|
|
91
91
|
void onPermissionStatusChange(const std::function<void(PermissionStatus /* status */)>& callback) override;
|
|
92
|
+
std::shared_ptr<Promise<bool>> openLocationSettings() override;
|
|
93
|
+
bool isAirplaneModeEnabled() override;
|
|
94
|
+
void onAirplaneModeChange(const std::function<void(bool /* isEnabled */)>& callback) override;
|
|
92
95
|
double getDistanceBetween(double lat1, double lon1, double lat2, double lon2) override;
|
|
93
96
|
double getDistanceToGeofence(const std::string& regionId) override;
|
|
94
97
|
void showLocalNotification(const std::string& title, const std::string& body) override;
|
|
@@ -227,6 +227,23 @@ abstract class HybridNitroLocationTrackingSpec: HybridObject() {
|
|
|
227
227
|
return __result
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
+
@DoNotStrip
|
|
231
|
+
@Keep
|
|
232
|
+
abstract fun openLocationSettings(): Promise<Boolean>
|
|
233
|
+
|
|
234
|
+
@DoNotStrip
|
|
235
|
+
@Keep
|
|
236
|
+
abstract fun isAirplaneModeEnabled(): Boolean
|
|
237
|
+
|
|
238
|
+
abstract fun onAirplaneModeChange(callback: (isEnabled: Boolean) -> Unit): Unit
|
|
239
|
+
|
|
240
|
+
@DoNotStrip
|
|
241
|
+
@Keep
|
|
242
|
+
private fun onAirplaneModeChange_cxx(callback: Func_void_bool): Unit {
|
|
243
|
+
val __result = onAirplaneModeChange(callback)
|
|
244
|
+
return __result
|
|
245
|
+
}
|
|
246
|
+
|
|
230
247
|
@DoNotStrip
|
|
231
248
|
@Keep
|
|
232
249
|
abstract fun getDistanceBetween(lat1: Double, lon1: Double, lat2: Double, lon2: Double): Double
|
|
@@ -33,6 +33,7 @@ target_sources(
|
|
|
33
33
|
# Autolinking Setup
|
|
34
34
|
../nitrogen/generated/android/nitrolocationtrackingOnLoad.cpp
|
|
35
35
|
# Shared Nitrogen C++ sources
|
|
36
|
+
../nitrogen/generated/shared/c++/HybridNitroLocationComplexLogicsCalculationSpec.cpp
|
|
36
37
|
../nitrogen/generated/shared/c++/HybridNitroLocationTrackingSpec.cpp
|
|
37
38
|
# Android-specific Nitrogen C++ sources
|
|
38
39
|
../nitrogen/generated/android/c++/JHybridNitroLocationTrackingSpec.cpp
|
|
@@ -330,6 +330,28 @@ namespace margelo::nitro::nitrolocationtracking {
|
|
|
330
330
|
std::rethrow_exception(__result.error());
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
|
+
inline std::shared_ptr<Promise<bool>> openLocationSettings() override {
|
|
334
|
+
auto __result = _swiftPart.openLocationSettings();
|
|
335
|
+
if (__result.hasError()) [[unlikely]] {
|
|
336
|
+
std::rethrow_exception(__result.error());
|
|
337
|
+
}
|
|
338
|
+
auto __value = std::move(__result.value());
|
|
339
|
+
return __value;
|
|
340
|
+
}
|
|
341
|
+
inline bool isAirplaneModeEnabled() override {
|
|
342
|
+
auto __result = _swiftPart.isAirplaneModeEnabled();
|
|
343
|
+
if (__result.hasError()) [[unlikely]] {
|
|
344
|
+
std::rethrow_exception(__result.error());
|
|
345
|
+
}
|
|
346
|
+
auto __value = std::move(__result.value());
|
|
347
|
+
return __value;
|
|
348
|
+
}
|
|
349
|
+
inline void onAirplaneModeChange(const std::function<void(bool /* isEnabled */)>& callback) override {
|
|
350
|
+
auto __result = _swiftPart.onAirplaneModeChange(callback);
|
|
351
|
+
if (__result.hasError()) [[unlikely]] {
|
|
352
|
+
std::rethrow_exception(__result.error());
|
|
353
|
+
}
|
|
354
|
+
}
|
|
333
355
|
inline double getDistanceBetween(double lat1, double lon1, double lat2, double lon2) override {
|
|
334
356
|
auto __result = _swiftPart.getDistanceBetween(std::forward<decltype(lat1)>(lat1), std::forward<decltype(lon1)>(lon1), std::forward<decltype(lat2)>(lat2), std::forward<decltype(lon2)>(lon2));
|
|
335
357
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -47,6 +47,9 @@ public protocol HybridNitroLocationTrackingSpec_protocol: HybridObject {
|
|
|
47
47
|
func getLocationPermissionStatus() throws -> PermissionStatus
|
|
48
48
|
func requestLocationPermission() throws -> Promise<PermissionStatus>
|
|
49
49
|
func onPermissionStatusChange(callback: @escaping (_ status: PermissionStatus) -> Void) throws -> Void
|
|
50
|
+
func openLocationSettings() throws -> Promise<Bool>
|
|
51
|
+
func isAirplaneModeEnabled() throws -> Bool
|
|
52
|
+
func onAirplaneModeChange(callback: @escaping (_ isEnabled: Bool) -> Void) throws -> Void
|
|
50
53
|
func getDistanceBetween(lat1: Double, lon1: Double, lat2: Double, lon2: Double) throws -> Double
|
|
51
54
|
func getDistanceToGeofence(regionId: String) throws -> Double
|
|
52
55
|
func showLocalNotification(title: String, body: String) throws -> Void
|
|
@@ -575,6 +575,53 @@ open class HybridNitroLocationTrackingSpec_cxx {
|
|
|
575
575
|
}
|
|
576
576
|
}
|
|
577
577
|
|
|
578
|
+
@inline(__always)
|
|
579
|
+
public final func openLocationSettings() -> bridge.Result_std__shared_ptr_Promise_bool___ {
|
|
580
|
+
do {
|
|
581
|
+
let __result = try self.__implementation.openLocationSettings()
|
|
582
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
|
|
583
|
+
let __promise = bridge.create_std__shared_ptr_Promise_bool__()
|
|
584
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
|
|
585
|
+
__result
|
|
586
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
587
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
588
|
+
return __promise
|
|
589
|
+
}()
|
|
590
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
|
|
591
|
+
} catch (let __error) {
|
|
592
|
+
let __exceptionPtr = __error.toCpp()
|
|
593
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
@inline(__always)
|
|
598
|
+
public final func isAirplaneModeEnabled() -> bridge.Result_bool_ {
|
|
599
|
+
do {
|
|
600
|
+
let __result = try self.__implementation.isAirplaneModeEnabled()
|
|
601
|
+
let __resultCpp = __result
|
|
602
|
+
return bridge.create_Result_bool_(__resultCpp)
|
|
603
|
+
} catch (let __error) {
|
|
604
|
+
let __exceptionPtr = __error.toCpp()
|
|
605
|
+
return bridge.create_Result_bool_(__exceptionPtr)
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
@inline(__always)
|
|
610
|
+
public final func onAirplaneModeChange(callback: bridge.Func_void_bool) -> bridge.Result_void_ {
|
|
611
|
+
do {
|
|
612
|
+
try self.__implementation.onAirplaneModeChange(callback: { () -> (Bool) -> Void in
|
|
613
|
+
let __wrappedFunction = bridge.wrap_Func_void_bool(callback)
|
|
614
|
+
return { (__isEnabled: Bool) -> Void in
|
|
615
|
+
__wrappedFunction.call(__isEnabled)
|
|
616
|
+
}
|
|
617
|
+
}())
|
|
618
|
+
return bridge.create_Result_void_()
|
|
619
|
+
} catch (let __error) {
|
|
620
|
+
let __exceptionPtr = __error.toCpp()
|
|
621
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
578
625
|
@inline(__always)
|
|
579
626
|
public final func getDistanceBetween(lat1: Double, lon1: Double, lat2: Double, lon2: Double) -> bridge.Result_double_ {
|
|
580
627
|
do {
|