react-native-geo-activity-kit 2.0.4 → 2.0.5
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/lib/module/index.js +37 -25
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +28 -14
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +63 -40
package/lib/module/index.js
CHANGED
|
@@ -1,35 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { NativeModules, NativeEventEmitter } from 'react-native';
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
|
|
4
|
+
// ✅ Fixed: Modern Type & Correct Import
|
|
5
|
+
|
|
6
|
+
const LINKING_ERROR = `The package 'react-native-geo-activity-kit' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
7
|
+
ios: "- You have run 'pod install'\n",
|
|
8
|
+
default: ''
|
|
9
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
10
|
+
|
|
11
|
+
// 1. Point to the CORRECT Native Module Name
|
|
12
|
+
const GeoActivityKit = NativeModules.GeoActivityKit ? NativeModules.GeoActivityKit : new Proxy({}, {
|
|
6
13
|
get() {
|
|
7
14
|
throw new Error(LINKING_ERROR);
|
|
8
15
|
}
|
|
9
16
|
});
|
|
10
|
-
const emitter = new NativeEventEmitter(
|
|
17
|
+
const emitter = new NativeEventEmitter(GeoActivityKit);
|
|
18
|
+
|
|
19
|
+
// 2. Define Types
|
|
20
|
+
|
|
21
|
+
// 3. Export the Object
|
|
11
22
|
export default {
|
|
12
|
-
// Service Control
|
|
13
|
-
startForegroundService: (title, body) =>
|
|
14
|
-
stopForegroundService: () =>
|
|
15
|
-
updateServiceNotification: (title, body) =>
|
|
16
|
-
//
|
|
17
|
-
startMotionDetector: (
|
|
18
|
-
stopMotionDetector: () =>
|
|
19
|
-
|
|
20
|
-
setLocationUpdateInterval:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// ---
|
|
28
|
-
|
|
23
|
+
// --- Service Control ---
|
|
24
|
+
startForegroundService: (title, body, id) => GeoActivityKit.startForegroundService(title, body, id),
|
|
25
|
+
stopForegroundService: () => GeoActivityKit.stopForegroundService(),
|
|
26
|
+
updateServiceNotification: (title, body) => GeoActivityKit.updateServiceNotification(title, body),
|
|
27
|
+
// --- Motion & Intelligence ---
|
|
28
|
+
startMotionDetector: (confidence = 75) => GeoActivityKit.startMotionDetector(confidence),
|
|
29
|
+
stopMotionDetector: () => GeoActivityKit.stopMotionDetector(),
|
|
30
|
+
// --- Location Control ---
|
|
31
|
+
setLocationUpdateInterval: ms => GeoActivityKit.setLocationUpdateInterval(ms),
|
|
32
|
+
// --- Alerts & Notifications ---
|
|
33
|
+
fireGeofenceAlert: (type, userName) => GeoActivityKit.fireGeofenceAlert(type, userName),
|
|
34
|
+
fireGenericAlert: (title, body, id) => GeoActivityKit.fireGenericAlert(title, body, id),
|
|
35
|
+
cancelGenericAlert: id => GeoActivityKit.cancelGenericAlert(id),
|
|
36
|
+
// --- GPS Status ---
|
|
37
|
+
registerGpsListener: () => GeoActivityKit.registerGpsListener(),
|
|
38
|
+
// --- Event Listeners ---
|
|
39
|
+
// Note: We cast event to 'any' to avoid TS strict object checks,
|
|
40
|
+
// and return EventSubscription (modern) instead of EmitterSubscription (deprecated).
|
|
41
|
+
|
|
29
42
|
addGpsStatusListener: cb => emitter.addListener('onGpsStatusChanged', event => cb(event)),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
addLocationErrorListener: cb => emitter.addListener('onLocationError', cb)
|
|
43
|
+
addMotionListener: cb => emitter.addListener('onMotionStateChanged', event => cb(event)),
|
|
44
|
+
addLocationLogListener: cb => emitter.addListener('onLocationLog', event => cb(event)),
|
|
45
|
+
addLocationErrorListener: cb => emitter.addListener('onLocationError', event => cb(event))
|
|
34
46
|
};
|
|
35
47
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","NativeEventEmitter","LINKING_ERROR","
|
|
1
|
+
{"version":3,"names":["NativeModules","NativeEventEmitter","Platform","LINKING_ERROR","select","ios","default","GeoActivityKit","Proxy","get","Error","emitter","startForegroundService","title","body","id","stopForegroundService","updateServiceNotification","startMotionDetector","confidence","stopMotionDetector","setLocationUpdateInterval","ms","fireGeofenceAlert","type","userName","fireGenericAlert","cancelGenericAlert","registerGpsListener","addGpsStatusListener","cb","addListener","event","addMotionListener","addLocationLogListener","addLocationErrorListener"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AACnB;;AAEvD,MAAMC,aAAa,GACjB,wFAAwF,GACxFD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA,MAAMC,cAAc,GAAGP,aAAa,CAACO,cAAc,GAC/CP,aAAa,CAACO,cAAc,GAC5B,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,MAAMQ,OAAO,GAAG,IAAIV,kBAAkB,CAACM,cAAc,CAAC;;AAEtD;;AAoBA;AACA,eAAe;EACb;EACAK,sBAAsB,EAAEA,CAACC,KAAa,EAAEC,IAAY,EAAEC,EAAU,KAC9DR,cAAc,CAACK,sBAAsB,CAACC,KAAK,EAAEC,IAAI,EAAEC,EAAE,CAAC;EAExDC,qBAAqB,EAAEA,CAAA,KACrBT,cAAc,CAACS,qBAAqB,CAAC,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AAiB,EAAGC,KAAU,IAAKF,EAAE,CAACE,KAAK,CAAC;AACpE,CAAC","ignoreList":[]}
|
|
@@ -1,23 +1,37 @@
|
|
|
1
|
+
import type { EventSubscription } from 'react-native';
|
|
2
|
+
export interface LocationEvent {
|
|
3
|
+
latitude: number;
|
|
4
|
+
longitude: number;
|
|
5
|
+
accuracy: number;
|
|
6
|
+
timestamp: string;
|
|
7
|
+
is_mock: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface MotionEvent {
|
|
10
|
+
activity: 'STILL' | 'WALKING' | 'RUNNING' | 'ON_BICYCLE' | 'IN_VEHICLE' | 'UNKNOWN';
|
|
11
|
+
isMoving: boolean;
|
|
12
|
+
state: 'MOVING' | 'STATIONARY';
|
|
13
|
+
}
|
|
14
|
+
export interface ErrorEvent {
|
|
15
|
+
error: string;
|
|
16
|
+
message: string;
|
|
17
|
+
}
|
|
1
18
|
declare const _default: {
|
|
2
|
-
startForegroundService: (title: string, body: string) => Promise<boolean>;
|
|
19
|
+
startForegroundService: (title: string, body: string, id: number) => Promise<boolean>;
|
|
3
20
|
stopForegroundService: () => Promise<boolean>;
|
|
4
21
|
updateServiceNotification: (title: string, body: string) => Promise<boolean>;
|
|
5
|
-
startMotionDetector: (
|
|
6
|
-
stopMotionDetector: () =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
fireGenericAlert: (title: string, body: string, id: number) => any;
|
|
12
|
-
cancelGenericAlert: (id: number) => any;
|
|
13
|
-
isAvailable: () => any;
|
|
22
|
+
startMotionDetector: (confidence?: number) => Promise<boolean>;
|
|
23
|
+
stopMotionDetector: () => Promise<boolean>;
|
|
24
|
+
setLocationUpdateInterval: (ms: number) => Promise<void>;
|
|
25
|
+
fireGeofenceAlert: (type: "IN" | "OUT", userName: string) => Promise<boolean>;
|
|
26
|
+
fireGenericAlert: (title: string, body: string, id: number) => Promise<boolean>;
|
|
27
|
+
cancelGenericAlert: (id: number) => Promise<boolean>;
|
|
14
28
|
registerGpsListener: () => Promise<boolean>;
|
|
15
29
|
addGpsStatusListener: (cb: (event: {
|
|
16
30
|
enabled: boolean;
|
|
17
|
-
}) => void) =>
|
|
18
|
-
addMotionListener: (cb: (event:
|
|
19
|
-
addLocationLogListener: (cb: (event:
|
|
20
|
-
addLocationErrorListener: (cb: (event:
|
|
31
|
+
}) => void) => EventSubscription;
|
|
32
|
+
addMotionListener: (cb: (event: MotionEvent) => void) => EventSubscription;
|
|
33
|
+
addLocationLogListener: (cb: (event: LocationEvent) => void) => EventSubscription;
|
|
34
|
+
addLocationErrorListener: (cb: (event: ErrorEvent) => void) => EventSubscription;
|
|
21
35
|
};
|
|
22
36
|
export default _default;
|
|
23
37
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAuBtD,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,YAAY,GAAG,YAAY,GAAG,SAAS,CAAC;IACpF,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,QAAQ,GAAG,YAAY,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;;oCAKiC,MAAM,QAAQ,MAAM,MAAM,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC;iCAGxD,OAAO,CAAC,OAAO,CAAC;uCAGR,MAAM,QAAQ,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC;uCAIxC,MAAM,KAAQ,OAAO,CAAC,OAAO,CAAC;8BAGxC,OAAO,CAAC,OAAO,CAAC;oCAIR,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;8BAI5B,IAAI,GAAG,KAAK,YAAY,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC;8BAGjD,MAAM,QAAQ,MAAM,MAAM,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC;6BAGpD,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC;+BAIzB,OAAO,CAAC,OAAO,CAAC;+BAOd,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,KAAG,iBAAiB;4BAG5D,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,KAAG,iBAAiB;iCAG3C,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,KAAG,iBAAiB;mCAGhD,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,KAAG,iBAAiB;;AAjDhF,wBAmDE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-geo-activity-kit",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "Battery-efficient location tracking with motion detection and native notifications.",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
package/src/index.tsx
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { NativeModules, NativeEventEmitter } from 'react-native';
|
|
1
|
+
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
|
|
2
|
+
import type { EventSubscription } from 'react-native'; // ✅ Fixed: Modern Type & Correct Import
|
|
2
3
|
|
|
3
4
|
const LINKING_ERROR =
|
|
4
5
|
`The package 'react-native-geo-activity-kit' doesn't seem to be linked. Make sure: \n\n` +
|
|
6
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
5
7
|
'- You rebuilt the app after installing the package\n' +
|
|
6
8
|
'- You are not using Expo Go\n';
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
// 1. Point to the CORRECT Native Module Name
|
|
11
|
+
const GeoActivityKit = NativeModules.GeoActivityKit
|
|
12
|
+
? NativeModules.GeoActivityKit
|
|
10
13
|
: new Proxy(
|
|
11
14
|
{},
|
|
12
15
|
{
|
|
@@ -16,58 +19,78 @@ const RNSensorModule = NativeModules.RNSensorModule
|
|
|
16
19
|
}
|
|
17
20
|
);
|
|
18
21
|
|
|
19
|
-
const emitter = new NativeEventEmitter(
|
|
20
|
-
|
|
22
|
+
const emitter = new NativeEventEmitter(GeoActivityKit);
|
|
23
|
+
|
|
24
|
+
// 2. Define Types
|
|
25
|
+
export interface LocationEvent {
|
|
26
|
+
latitude: number;
|
|
27
|
+
longitude: number;
|
|
28
|
+
accuracy: number;
|
|
29
|
+
timestamp: string;
|
|
30
|
+
is_mock: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface MotionEvent {
|
|
34
|
+
activity: 'STILL' | 'WALKING' | 'RUNNING' | 'ON_BICYCLE' | 'IN_VEHICLE' | 'UNKNOWN';
|
|
35
|
+
isMoving: boolean;
|
|
36
|
+
state: 'MOVING' | 'STATIONARY';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ErrorEvent {
|
|
40
|
+
error: string;
|
|
41
|
+
message: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 3. Export the Object
|
|
21
45
|
export default {
|
|
22
|
-
// Service Control
|
|
23
|
-
startForegroundService: (title: string, body: string): Promise<boolean> =>
|
|
24
|
-
|
|
46
|
+
// --- Service Control ---
|
|
47
|
+
startForegroundService: (title: string, body: string, id: number): Promise<boolean> =>
|
|
48
|
+
GeoActivityKit.startForegroundService(title, body, id),
|
|
25
49
|
|
|
26
50
|
stopForegroundService: (): Promise<boolean> =>
|
|
27
|
-
|
|
51
|
+
GeoActivityKit.stopForegroundService(),
|
|
28
52
|
|
|
29
53
|
updateServiceNotification: (title: string, body: string): Promise<boolean> =>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// Sensors & Configuration
|
|
33
|
-
startMotionDetector: (threshold: number = 0.8) =>
|
|
34
|
-
RNSensorModule.startMotionDetector(threshold),
|
|
35
|
-
|
|
36
|
-
stopMotionDetector: () => RNSensorModule.stopMotionDetector(),
|
|
37
|
-
|
|
38
|
-
setUpdateInterval: (ms: number = 100) => RNSensorModule.setUpdateInterval(ms),
|
|
54
|
+
GeoActivityKit.updateServiceNotification(title, body),
|
|
39
55
|
|
|
40
|
-
|
|
41
|
-
|
|
56
|
+
// --- Motion & Intelligence ---
|
|
57
|
+
startMotionDetector: (confidence: number = 75): Promise<boolean> =>
|
|
58
|
+
GeoActivityKit.startMotionDetector(confidence),
|
|
42
59
|
|
|
43
|
-
|
|
44
|
-
|
|
60
|
+
stopMotionDetector: (): Promise<boolean> =>
|
|
61
|
+
GeoActivityKit.stopMotionDetector(),
|
|
45
62
|
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
|
|
63
|
+
// --- Location Control ---
|
|
64
|
+
setLocationUpdateInterval: (ms: number): Promise<void> =>
|
|
65
|
+
GeoActivityKit.setLocationUpdateInterval(ms),
|
|
49
66
|
|
|
50
|
-
|
|
51
|
-
|
|
67
|
+
// --- Alerts & Notifications ---
|
|
68
|
+
fireGeofenceAlert: (type: 'IN' | 'OUT', userName: string): Promise<boolean> =>
|
|
69
|
+
GeoActivityKit.fireGeofenceAlert(type, userName),
|
|
52
70
|
|
|
53
|
-
|
|
71
|
+
fireGenericAlert: (title: string, body: string, id: number): Promise<boolean> =>
|
|
72
|
+
GeoActivityKit.fireGenericAlert(title, body, id),
|
|
54
73
|
|
|
55
|
-
|
|
74
|
+
cancelGenericAlert: (id: number): Promise<boolean> =>
|
|
75
|
+
GeoActivityKit.cancelGenericAlert(id),
|
|
56
76
|
|
|
57
|
-
// ---
|
|
77
|
+
// --- GPS Status ---
|
|
58
78
|
registerGpsListener: (): Promise<boolean> =>
|
|
59
|
-
|
|
79
|
+
GeoActivityKit.registerGpsListener(),
|
|
60
80
|
|
|
61
|
-
|
|
81
|
+
// --- Event Listeners ---
|
|
82
|
+
// Note: We cast event to 'any' to avoid TS strict object checks,
|
|
83
|
+
// and return EventSubscription (modern) instead of EmitterSubscription (deprecated).
|
|
84
|
+
|
|
85
|
+
addGpsStatusListener: (cb: (event: { enabled: boolean }) => void): EventSubscription =>
|
|
62
86
|
emitter.addListener('onGpsStatusChanged', (event: any) => cb(event)),
|
|
63
87
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
emitter.addListener('onMotionStateChanged', cb),
|
|
88
|
+
addMotionListener: (cb: (event: MotionEvent) => void): EventSubscription =>
|
|
89
|
+
emitter.addListener('onMotionStateChanged', (event: any) => cb(event)),
|
|
67
90
|
|
|
68
|
-
addLocationLogListener: (cb: (event:
|
|
69
|
-
emitter.addListener('onLocationLog', cb),
|
|
91
|
+
addLocationLogListener: (cb: (event: LocationEvent) => void): EventSubscription =>
|
|
92
|
+
emitter.addListener('onLocationLog', (event: any) => cb(event)),
|
|
70
93
|
|
|
71
|
-
addLocationErrorListener: (cb: (event:
|
|
72
|
-
emitter.addListener('onLocationError', cb),
|
|
73
|
-
};
|
|
94
|
+
addLocationErrorListener: (cb: (event: ErrorEvent) => void): EventSubscription =>
|
|
95
|
+
emitter.addListener('onLocationError', (event: any) => cb(event)),
|
|
96
|
+
};
|