react-native-nitro-location-tracking 0.1.6 → 0.1.7
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/android/src/main/java/com/margelo/nitro/nitrolocationtracking/LocationEngine.kt +8 -9
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/NativeDBWriter.kt +61 -53
- package/ios/NativeDBWriter.swift +2 -1
- package/ios/NitroLocationTracking.swift +4 -3
- package/lib/typescript/src/NitroLocationTracking.nitro.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/NitroLocationTracking.nitro.ts +13 -10
|
@@ -9,7 +9,6 @@ import android.os.Looper
|
|
|
9
9
|
import android.provider.Settings
|
|
10
10
|
import android.util.Log
|
|
11
11
|
import com.google.android.gms.location.*
|
|
12
|
-
import kotlin.coroutines.resume
|
|
13
12
|
|
|
14
13
|
class LocationEngine(private val context: Context) {
|
|
15
14
|
companion object {
|
|
@@ -23,7 +22,7 @@ class LocationEngine(private val context: Context) {
|
|
|
23
22
|
var onLocation: ((LocationData) -> Unit)? = null
|
|
24
23
|
var onMotionChange: ((Boolean) -> Unit)? = null
|
|
25
24
|
var dbWriter: NativeDBWriter? = null
|
|
26
|
-
var currentRideId: String? = null
|
|
25
|
+
// var currentRideId: String? = null
|
|
27
26
|
var rejectMockLocations: Boolean = false
|
|
28
27
|
val speedMonitor = SpeedMonitor()
|
|
29
28
|
val tripCalculator = TripCalculator()
|
|
@@ -82,13 +81,13 @@ class LocationEngine(private val context: Context) {
|
|
|
82
81
|
}
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
suspend fun getCurrentLocationSuspend(): LocationData? {
|
|
86
|
-
return kotlin.coroutines.suspendCoroutine { cont ->
|
|
87
|
-
getCurrentLocation { data ->
|
|
88
|
-
cont.resume(data)
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
84
|
+
// suspend fun getCurrentLocationSuspend(): LocationData? {
|
|
85
|
+
// return kotlin.coroutines.suspendCoroutine { cont ->
|
|
86
|
+
// getCurrentLocation { data ->
|
|
87
|
+
// cont.resume(data)
|
|
88
|
+
// }
|
|
89
|
+
// }
|
|
90
|
+
// }
|
|
92
91
|
|
|
93
92
|
private fun processLocation(location: Location) {
|
|
94
93
|
val data = locationToData(location)
|
|
@@ -7,10 +7,11 @@ import android.database.sqlite.SQLiteOpenHelper
|
|
|
7
7
|
import java.util.UUID
|
|
8
8
|
|
|
9
9
|
class NativeDBWriter(context: Context) :
|
|
10
|
-
|
|
10
|
+
SQLiteOpenHelper(context, "nitro_location.db", null, 1) {
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
override fun onCreate(db: SQLiteDatabase) {
|
|
13
|
+
db.execSQL(
|
|
14
|
+
"""
|
|
14
15
|
CREATE TABLE IF NOT EXISTS locations (
|
|
15
16
|
id TEXT PRIMARY KEY,
|
|
16
17
|
latitude REAL NOT NULL, longitude REAL NOT NULL,
|
|
@@ -19,62 +20,69 @@ class NativeDBWriter(context: Context) :
|
|
|
19
20
|
synced INTEGER DEFAULT 0, retry_count INTEGER DEFAULT 0,
|
|
20
21
|
created_at INTEGER DEFAULT (strftime('%s','now') * 1000)
|
|
21
22
|
)
|
|
22
|
-
"""
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
"""
|
|
24
|
+
)
|
|
25
|
+
db.execSQL("CREATE INDEX IF NOT EXISTS idx_locations_synced ON locations(synced)")
|
|
26
|
+
db.execSQL("CREATE INDEX IF NOT EXISTS idx_locations_timestamp ON locations(timestamp)")
|
|
27
|
+
db.execSQL("CREATE INDEX IF NOT EXISTS idx_locations_ride_id ON locations(ride_id)")
|
|
28
|
+
db.execSQL("PRAGMA journal_mode = WAL")
|
|
29
|
+
}
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
override fun onUpgrade(db: SQLiteDatabase, old: Int, new: Int) {}
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
fun insert(location: LocationData, rideId: String? = null) {
|
|
34
|
+
writableDatabase.insert("locations", null, ContentValues().apply {
|
|
35
|
+
put("id", UUID.randomUUID().toString())
|
|
36
|
+
put("latitude", location.latitude)
|
|
37
|
+
put("longitude", location.longitude)
|
|
38
|
+
put("altitude", location.altitude)
|
|
39
|
+
put("speed", location.speed)
|
|
40
|
+
put("bearing", location.bearing)
|
|
41
|
+
put("accuracy", location.accuracy)
|
|
42
|
+
put("timestamp", location.timestamp.toLong())
|
|
43
|
+
put("ride_id", rideId)
|
|
44
|
+
put("synced", 0)
|
|
45
|
+
})
|
|
46
|
+
}
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
48
|
+
fun getUnsyncedBatch(limit: Int): List<Pair<String, LocationData>> {
|
|
49
|
+
val list = mutableListOf<Pair<String, LocationData>>()
|
|
50
|
+
readableDatabase.query(
|
|
51
|
+
"locations", null, "synced = 0",
|
|
52
|
+
null, null, null, "timestamp ASC", "$limit"
|
|
53
|
+
).use {
|
|
54
|
+
while (it.moveToNext()) {
|
|
55
|
+
val id = it.getString(it.getColumnIndexOrThrow("id"))
|
|
56
|
+
val data = LocationData(
|
|
57
|
+
latitude = it.getDouble(it.getColumnIndexOrThrow("latitude")),
|
|
58
|
+
longitude = it.getDouble(it.getColumnIndexOrThrow("longitude")),
|
|
59
|
+
altitude = it.getDouble(it.getColumnIndexOrThrow("altitude")),
|
|
60
|
+
speed = it.getDouble(it.getColumnIndexOrThrow("speed")),
|
|
61
|
+
bearing = it.getDouble(it.getColumnIndexOrThrow("bearing")),
|
|
62
|
+
accuracy = it.getDouble(it.getColumnIndexOrThrow("accuracy")),
|
|
63
|
+
timestamp = it.getLong(it.getColumnIndexOrThrow("timestamp")).toDouble(),
|
|
64
|
+
isMockLocation = false
|
|
65
|
+
)
|
|
66
|
+
list.add(Pair(id, data))
|
|
67
|
+
}
|
|
65
68
|
}
|
|
69
|
+
return list
|
|
70
|
+
}
|
|
66
71
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
fun markSynced(ids: List<String>) {
|
|
73
|
+
val ph = ids.joinToString(",") { "?" }
|
|
74
|
+
writableDatabase.execSQL(
|
|
75
|
+
"UPDATE locations SET synced = 1 WHERE id IN ($ph)",
|
|
76
|
+
ids.toTypedArray()
|
|
77
|
+
)
|
|
78
|
+
}
|
|
73
79
|
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
fun clearOldSynced() {
|
|
81
|
+
writableDatabase.execSQL(
|
|
82
|
+
"""
|
|
76
83
|
DELETE FROM locations WHERE synced = 1
|
|
77
84
|
AND timestamp < (strftime('%s','now') * 1000 - 86400000)
|
|
78
|
-
"""
|
|
79
|
-
|
|
85
|
+
"""
|
|
86
|
+
)
|
|
87
|
+
}
|
|
80
88
|
}
|
package/ios/NativeDBWriter.swift
CHANGED
|
@@ -85,7 +85,8 @@ class NativeDBWriter {
|
|
|
85
85
|
speed: sqlite3_column_double(stmt, 4),
|
|
86
86
|
bearing: sqlite3_column_double(stmt, 5),
|
|
87
87
|
accuracy: sqlite3_column_double(stmt, 6),
|
|
88
|
-
timestamp: Double(sqlite3_column_int64(stmt, 7))
|
|
88
|
+
timestamp: Double(sqlite3_column_int64(stmt, 7)),
|
|
89
|
+
isMockLocation:true // we need to check here
|
|
89
90
|
)
|
|
90
91
|
results.append((id: id, data: data))
|
|
91
92
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Foundation
|
|
2
|
+
import CoreLocation
|
|
2
3
|
import NitroModules
|
|
3
4
|
|
|
4
5
|
class NitroLocationTracking: HybridNitroLocationTrackingSpec {
|
|
@@ -197,17 +198,17 @@ class NitroLocationTracking: HybridNitroLocationTrackingSpec {
|
|
|
197
198
|
|
|
198
199
|
switch status {
|
|
199
200
|
case .notDetermined:
|
|
200
|
-
|
|
201
|
+
return .notdetermined
|
|
201
202
|
case .restricted:
|
|
202
203
|
return .restricted
|
|
203
204
|
case .denied:
|
|
204
205
|
return .denied
|
|
205
206
|
case .authorizedWhenInUse:
|
|
206
|
-
return .
|
|
207
|
+
return .wheninuse
|
|
207
208
|
case .authorizedAlways:
|
|
208
209
|
return .always
|
|
209
210
|
@unknown default:
|
|
210
|
-
return .
|
|
211
|
+
return .notdetermined
|
|
211
212
|
}
|
|
212
213
|
}
|
|
213
214
|
|
|
@@ -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,CAAC;AACxD,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,cAAc,GAAG,cAAc,CAAC;AAI5E,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,eAAe,EAA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AAM,EAAE,WAAW,GAAG,IAAI,CAAC;IACjD,YAAY,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACjD,eAAe,IAAI,MAAM,CAAC;IAG1B,oBAAoB,IAAI,IAAI,CAAC;IAC7B,mBAAmB,IAAI,SAAS,CAAC;IACjC,YAAY,IAAI,SAAS,CAAC;IAC1B,oBAAoB,IAAI,IAAI,CAAC;IAG7B,yBAAyB,IAAI,OAAO,CAAC;IACrC,sBAAsB,CAAC,QAAQ,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAG/D,2BAA2B,IAAI,gBAAgB,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-location-tracking",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
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",
|
|
@@ -171,4 +171,4 @@
|
|
|
171
171
|
],
|
|
172
172
|
"version": "0.57.2"
|
|
173
173
|
}
|
|
174
|
-
}
|
|
174
|
+
}
|
|
@@ -48,7 +48,7 @@ export interface GeofenceRegion {
|
|
|
48
48
|
id: string;
|
|
49
49
|
latitude: number;
|
|
50
50
|
longitude: number;
|
|
51
|
-
radius: number;
|
|
51
|
+
radius: number; // meters
|
|
52
52
|
notifyOnEntry: boolean;
|
|
53
53
|
notifyOnExit: boolean;
|
|
54
54
|
}
|
|
@@ -57,20 +57,23 @@ export type GeofenceEvent = 'enter' | 'exit';
|
|
|
57
57
|
export type GeofenceCallback = (event: GeofenceEvent, regionId: string) => void;
|
|
58
58
|
|
|
59
59
|
export interface SpeedConfig {
|
|
60
|
-
maxSpeedKmh: number;
|
|
61
|
-
minSpeedKmh: number;
|
|
62
|
-
checkIntervalMs: number;
|
|
60
|
+
maxSpeedKmh: number; // speed limit in km/h
|
|
61
|
+
minSpeedKmh: number; // minimum speed threshold
|
|
62
|
+
checkIntervalMs: number; // how often to evaluate
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export type SpeedAlertType = 'exceeded' | 'normalized' | 'below_minimum';
|
|
66
|
-
export type SpeedAlertCallback = (
|
|
66
|
+
export type SpeedAlertCallback = (
|
|
67
|
+
alert: SpeedAlertType,
|
|
68
|
+
currentSpeedKmh: number
|
|
69
|
+
) => void;
|
|
67
70
|
|
|
68
71
|
export interface TripStats {
|
|
69
|
-
distanceMeters: number;
|
|
70
|
-
durationMs: number;
|
|
71
|
-
averageSpeedKmh: number;
|
|
72
|
-
maxSpeedKmh: number;
|
|
73
|
-
pointCount: number;
|
|
72
|
+
distanceMeters: number; // total distance traveled
|
|
73
|
+
durationMs: number; // elapsed time since start
|
|
74
|
+
averageSpeedKmh: number; // average speed
|
|
75
|
+
maxSpeedKmh: number; // peak speed recorded
|
|
76
|
+
pointCount: number; // number of location samples
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
export type LocationProviderStatus = 'enabled' | 'disabled';
|