react-native-geo-activity-kit 1.2.5 → 2.0.0
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 +55 -45
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +28 -36
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +102 -81
package/lib/module/index.js
CHANGED
|
@@ -1,52 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { NativeModules,
|
|
4
|
-
const LINKING_ERROR = `The package 'react-native-geo-activity-kit' doesn't seem to be linked. Make sure: \n\n` +
|
|
5
|
-
|
|
3
|
+
import { NativeModules, Platform } from 'react-native';
|
|
4
|
+
const LINKING_ERROR = `The package 'react-native-geo-activity-kit' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
5
|
+
ios: "- You have run 'pod install'\n",
|
|
6
|
+
default: ''
|
|
7
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
8
|
+
|
|
9
|
+
// 1. Get the Native Module
|
|
10
|
+
const GeoActivityKit = NativeModules.GeoActivityKit ? NativeModules.GeoActivityKit : new Proxy({}, {
|
|
6
11
|
get() {
|
|
7
12
|
throw new Error(LINKING_ERROR);
|
|
8
13
|
}
|
|
9
14
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
15
|
+
|
|
16
|
+
// 2. Define Types for Events
|
|
17
|
+
|
|
18
|
+
// 3. Export Functions (Named Exports)
|
|
19
|
+
|
|
20
|
+
// --- Service Control ---
|
|
21
|
+
export function startForegroundService(title, body, id) {
|
|
22
|
+
return GeoActivityKit.startForegroundService(title, body, id);
|
|
23
|
+
}
|
|
24
|
+
export function stopForegroundService() {
|
|
25
|
+
return GeoActivityKit.stopForegroundService();
|
|
26
|
+
}
|
|
27
|
+
export function updateServiceNotification(title, body) {
|
|
28
|
+
return GeoActivityKit.updateServiceNotification(title, body);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// --- Motion & Intelligence ---
|
|
32
|
+
export function startMotionDetector(confidence) {
|
|
33
|
+
return GeoActivityKit.startMotionDetector(confidence);
|
|
34
|
+
}
|
|
35
|
+
export function stopMotionDetector() {
|
|
36
|
+
return GeoActivityKit.stopMotionDetector();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// --- Location Control ---
|
|
40
|
+
export function setLocationUpdateInterval(intervalMs) {
|
|
41
|
+
return GeoActivityKit.setLocationUpdateInterval(intervalMs);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// --- Alerts & Notifications ---
|
|
45
|
+
export function fireGeofenceAlert(type, userName) {
|
|
46
|
+
return GeoActivityKit.fireGeofenceAlert(type, userName);
|
|
47
|
+
}
|
|
48
|
+
export function fireGenericAlert(title, body, id) {
|
|
49
|
+
return GeoActivityKit.fireGenericAlert(title, body, id);
|
|
50
|
+
}
|
|
51
|
+
export function cancelGenericAlert(id) {
|
|
52
|
+
return GeoActivityKit.cancelGenericAlert(id);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// --- GPS Status ---
|
|
56
|
+
export function registerGpsListener() {
|
|
57
|
+
return GeoActivityKit.registerGpsListener();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 4. Default Export
|
|
61
|
+
export default GeoActivityKit;
|
|
52
62
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","GeoActivityKit","Proxy","get","Error","startForegroundService","title","body","id","stopForegroundService","updateServiceNotification","startMotionDetector","confidence","stopMotionDetector","setLocationUpdateInterval","intervalMs","fireGeofenceAlert","type","userName","fireGenericAlert","cancelGenericAlert","registerGpsListener"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,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,GAAGN,aAAa,CAACM,cAAc,GAC/CN,aAAa,CAACM,cAAc,GAC5B,IAAIC,KAAK,CACT,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;;AAEH;;AA0BA;;AAEA;AACA,OAAO,SAASQ,sBAAsBA,CACpCC,KAAa,EACbC,IAAY,EACZC,EAAU,EACQ;EAClB,OAAOP,cAAc,CAACI,sBAAsB,CAACC,KAAK,EAAEC,IAAI,EAAEC,EAAE,CAAC;AAC/D;AAEA,OAAO,SAASC,qBAAqBA,CAAA,EAAqB;EACxD,OAAOR,cAAc,CAACQ,qBAAqB,CAAC,CAAC;AAC/C;AAEA,OAAO,SAASC,yBAAyBA,CACvCJ,KAAa,EACbC,IAAY,EACM;EAClB,OAAON,cAAc,CAAC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
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* accuracy: number,
|
|
30
|
-
* is_mock: boolean (NEW: Detects Fake GPS)
|
|
31
|
-
* }
|
|
32
|
-
*/
|
|
33
|
-
addLocationLogListener: (cb: (event: any) => void) => import("react-native").EventSubscription;
|
|
34
|
-
addLocationErrorListener: (cb: (event: any) => void) => import("react-native").EventSubscription;
|
|
35
|
-
};
|
|
36
|
-
export default _default;
|
|
1
|
+
declare const GeoActivityKit: any;
|
|
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
|
+
}
|
|
18
|
+
export declare function startForegroundService(title: string, body: string, id: number): Promise<boolean>;
|
|
19
|
+
export declare function stopForegroundService(): Promise<boolean>;
|
|
20
|
+
export declare function updateServiceNotification(title: string, body: string): Promise<boolean>;
|
|
21
|
+
export declare function startMotionDetector(confidence: number): Promise<boolean>;
|
|
22
|
+
export declare function stopMotionDetector(): Promise<boolean>;
|
|
23
|
+
export declare function setLocationUpdateInterval(intervalMs: number): Promise<void>;
|
|
24
|
+
export declare function fireGeofenceAlert(type: 'IN' | 'OUT', userName: string): Promise<boolean>;
|
|
25
|
+
export declare function fireGenericAlert(title: string, body: string, id: number): Promise<boolean>;
|
|
26
|
+
export declare function cancelGenericAlert(id: number): Promise<boolean>;
|
|
27
|
+
export declare function registerGpsListener(): Promise<boolean>;
|
|
28
|
+
export default GeoActivityKit;
|
|
37
29
|
//# 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":"AASA,QAAA,MAAM,cAAc,KASjB,CAAC;AAGJ,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,EACN,OAAO,GACP,SAAS,GACT,SAAS,GACT,YAAY,GACZ,YAAY,GACZ,SAAS,CAAC;IACZ,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;AAKD,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,OAAO,CAAC,CAElB;AAED,wBAAgB,qBAAqB,IAAI,OAAO,CAAC,OAAO,CAAC,CAExD;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC,CAElB;AAGD,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAExE;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC,CAErD;AAGD,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3E;AAGD,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,IAAI,GAAG,KAAK,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,CAElB;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,OAAO,CAAC,CAElB;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE/D;AAGD,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAEtD;AAGD,eAAe,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-geo-activity-kit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
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,88 +1,109 @@
|
|
|
1
|
-
import { NativeModules,
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
2
|
|
|
3
3
|
const LINKING_ERROR =
|
|
4
4
|
`The package 'react-native-geo-activity-kit' doesn't seem to be linked. Make sure: \n\n` +
|
|
5
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
5
6
|
'- You rebuilt the app after installing the package\n' +
|
|
6
7
|
'- You are not using Expo Go\n';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
// 1. Get the Native Module
|
|
10
|
+
const GeoActivityKit = NativeModules.GeoActivityKit
|
|
11
|
+
? NativeModules.GeoActivityKit
|
|
10
12
|
: new Proxy(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
13
|
+
{},
|
|
14
|
+
{
|
|
15
|
+
get() {
|
|
16
|
+
throw new Error(LINKING_ERROR);
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
// 2. Define Types for Events
|
|
22
|
+
export interface LocationEvent {
|
|
23
|
+
latitude: number;
|
|
24
|
+
longitude: number;
|
|
25
|
+
accuracy: number;
|
|
26
|
+
timestamp: string;
|
|
27
|
+
is_mock: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface MotionEvent {
|
|
31
|
+
activity:
|
|
32
|
+
| 'STILL'
|
|
33
|
+
| 'WALKING'
|
|
34
|
+
| 'RUNNING'
|
|
35
|
+
| 'ON_BICYCLE'
|
|
36
|
+
| 'IN_VEHICLE'
|
|
37
|
+
| 'UNKNOWN';
|
|
38
|
+
isMoving: boolean;
|
|
39
|
+
state: 'MOVING' | 'STATIONARY';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ErrorEvent {
|
|
43
|
+
error: string;
|
|
44
|
+
message: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 3. Export Functions (Named Exports)
|
|
48
|
+
|
|
49
|
+
// --- Service Control ---
|
|
50
|
+
export function startForegroundService(
|
|
51
|
+
title: string,
|
|
52
|
+
body: string,
|
|
53
|
+
id: number
|
|
54
|
+
): Promise<boolean> {
|
|
55
|
+
return GeoActivityKit.startForegroundService(title, body, id);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function stopForegroundService(): Promise<boolean> {
|
|
59
|
+
return GeoActivityKit.stopForegroundService();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function updateServiceNotification(
|
|
63
|
+
title: string,
|
|
64
|
+
body: string
|
|
65
|
+
): Promise<boolean> {
|
|
66
|
+
return GeoActivityKit.updateServiceNotification(title, body);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// --- Motion & Intelligence ---
|
|
70
|
+
export function startMotionDetector(confidence: number): Promise<boolean> {
|
|
71
|
+
return GeoActivityKit.startMotionDetector(confidence);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function stopMotionDetector(): Promise<boolean> {
|
|
75
|
+
return GeoActivityKit.stopMotionDetector();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// --- Location Control ---
|
|
79
|
+
export function setLocationUpdateInterval(intervalMs: number): Promise<void> {
|
|
80
|
+
return GeoActivityKit.setLocationUpdateInterval(intervalMs);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// --- Alerts & Notifications ---
|
|
84
|
+
export function fireGeofenceAlert(
|
|
85
|
+
type: 'IN' | 'OUT',
|
|
86
|
+
userName: string
|
|
87
|
+
): Promise<boolean> {
|
|
88
|
+
return GeoActivityKit.fireGeofenceAlert(type, userName);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function fireGenericAlert(
|
|
92
|
+
title: string,
|
|
93
|
+
body: string,
|
|
94
|
+
id: number
|
|
95
|
+
): Promise<boolean> {
|
|
96
|
+
return GeoActivityKit.fireGenericAlert(title, body, id);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function cancelGenericAlert(id: number): Promise<boolean> {
|
|
100
|
+
return GeoActivityKit.cancelGenericAlert(id);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// --- GPS Status ---
|
|
104
|
+
export function registerGpsListener(): Promise<boolean> {
|
|
105
|
+
return GeoActivityKit.registerGpsListener();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// 4. Default Export
|
|
109
|
+
export default GeoActivityKit;
|