react-native-geo-activity-kit 1.2.5 → 2.0.1

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.
@@ -1,52 +1,29 @@
1
1
  "use strict";
2
2
 
3
- import { NativeModules, NativeEventEmitter } from 'react-native';
4
- const LINKING_ERROR = `The package 'react-native-geo-activity-kit' doesn't seem to be linked. Make sure: \n\n` + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
5
- const RNSensorModule = NativeModules.RNSensorModule ? NativeModules.RNSensorModule : new Proxy({}, {
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
+ const GeoActivityKit = NativeModules.GeoActivityKit ? NativeModules.GeoActivityKit : new Proxy({}, {
6
9
  get() {
7
10
  throw new Error(LINKING_ERROR);
8
11
  }
9
12
  });
10
- const emitter = new NativeEventEmitter(RNSensorModule);
11
- export default {
12
- // --- SERVICE CONTROL ---
13
- startForegroundService: (title, body) => RNSensorModule.startForegroundService(title, body),
14
- stopForegroundService: () => RNSensorModule.stopForegroundService(),
15
- updateServiceNotification: (title, body) => RNSensorModule.updateServiceNotification(title, body),
16
- // --- MOTION DETECTION (ACTIVITY RECOGNITION) ---
17
- // Note: Threshold is ignored by the new native engine, but kept for compatibility
18
- startMotionDetector: (threshold = 0.8) => RNSensorModule.startMotionDetector(threshold),
19
- stopMotionDetector: () => RNSensorModule.stopMotionDetector(),
20
- // --- LOCATION CONTROL ---
21
- setLocationUpdateInterval: (ms = 90000) => RNSensorModule.setLocationUpdateInterval(ms),
22
- // --- ALERTS ---
23
- fireGeofenceAlert: (type, userName) => RNSensorModule.fireGeofenceAlert(type, userName),
24
- fireGenericAlert: (title, body, id) => RNSensorModule.fireGenericAlert(title, body, id),
25
- cancelGenericAlert: id => RNSensorModule.cancelGenericAlert(id),
26
- // --- GPS STATUS ---
27
- registerGpsListener: () => RNSensorModule.registerGpsListener(),
28
- addGpsStatusListener: cb => emitter.addListener('onGpsStatusChanged', event => cb(event)),
29
- // --- EVENT LISTENERS ---
30
-
31
- /**
32
- * Returns:
33
- * {
34
- * activity: "WALKING" | "STILL" | "IN_VEHICLE" ...,
35
- * isMoving: boolean,
36
- * state: "MOVING" | "STATIONARY" (Legacy support)
37
- * }
38
- */
39
- addMotionListener: cb => emitter.addListener('onMotionStateChanged', cb),
40
- /**
41
- * Returns:
42
- * {
43
- * latitude: number,
44
- * longitude: number,
45
- * accuracy: number,
46
- * is_mock: boolean (NEW: Detects Fake GPS)
47
- * }
48
- */
49
- addLocationLogListener: cb => emitter.addListener('onLocationLog', cb),
50
- addLocationErrorListener: cb => emitter.addListener('onLocationError', cb)
51
- };
13
+ export function startForegroundService(title, body, id) {
14
+ return GeoActivityKit.startForegroundService(title, body, id);
15
+ }
16
+ export function stopForegroundService() {
17
+ return GeoActivityKit.stopForegroundService();
18
+ }
19
+ export function startMotionDetector(confidence) {
20
+ return GeoActivityKit.startMotionDetector(confidence);
21
+ }
22
+ export function stopMotionDetector() {
23
+ return GeoActivityKit.stopMotionDetector();
24
+ }
25
+ export function setLocationUpdateInterval(intervalMs) {
26
+ return GeoActivityKit.setLocationUpdateInterval(intervalMs);
27
+ }
28
+ export default GeoActivityKit;
52
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","NativeEventEmitter","LINKING_ERROR","RNSensorModule","Proxy","get","Error","emitter","startForegroundService","title","body","stopForegroundService","updateServiceNotification","startMotionDetector","threshold","stopMotionDetector","setLocationUpdateInterval","ms","fireGeofenceAlert","type","userName","fireGenericAlert","id","cancelGenericAlert","registerGpsListener","addGpsStatusListener","cb","addListener","event","addMotionListener","addLocationLogListener","addLocationErrorListener"],"sourceRoot":"../../src","sources":["index.tsx"],"mapp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AGD,EAAU,IAC7BnB,cAAc,CAACoB,kBAAkB,CAACD,EAAE,CAAC;EAEvC;EACAE,mBAAmB,EAAEA,CAAA,KACnBrB,cAAc,CAACqB,mBAAmB,CAAC,CAAC;EAEtCC,oBAAoB,EAAGC,EAAyC,IAC9DnB,OAAO,CAACoB,WAAW,CAAC,oBAAoB,EAAGC,KAAU,IAAKF,EAAE,CAACE,KAAK,CAAC,CAAC;EAEtE;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,iBAAiB,EAAGH,EAAwB,IAC1CnB,OAAO,CAACoB,WAAW,CAAC,sBAAsB,EAAED,EAAE,CAAC;EAEjD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEI,sBAAsB,EAAGJ,EAAwB,IAC/CnB,OAAO,CAACoB,WAAW,CAAC,eAAe,EAAED,EAAE,CAAC;EAE1CK,wBAAwB,EAAGL,EAAwB,IACjDnB,OAAO,CAACoB,WAAW,CAAC,iBAAiB,EAAED,EAAE;AAC7C,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","GeoActivityKit","Proxy","get","Error","startForegroundService","title","body","id","stopForegroundService","startMotionDetector","confidence","stopMotionDetector","setLocationUpdateInterval","intervalMs"],"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,MAAMC,cAAc,GAAGN,aAAa,CAACM,cAAc,GAC/CN,aAAa,CAACM,cAAc,GAC5B,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AA2BL,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,mBAAmBA,CAACC,UAAkB,EAAoB;EACxE,OAAOV,cAAc,CAACS,mBAAmB,CAACC,UAAU,CAAC;AACvD;AAEA,OAAO,SAASC,kBAAkBA,CAAA,EAAqB;EACrD,OAAOX,cAAc,CAACW,kBAAkB,CAAC,CAAC;AAC5C;AAEA,OAAO,SAASC,yBAAyBA,CAACC,UAAkB,EAAiB;EAC3E,OAAOb,cAAc,CAACY,yBAAyB,CAACC,UAAU,CAAC;AAC7D;AAEA,eAAeb,cAAc","ignoreList":[]}
@@ -1,37 +1,24 @@
1
- declare const _default: {
2
- startForegroundService: (title: string, body: string) => Promise<boolean>;
3
- stopForegroundService: () => Promise<boolean>;
4
- updateServiceNotification: (title: string, body: string) => Promise<boolean>;
5
- startMotionDetector: (threshold?: number) => Promise<boolean>;
6
- stopMotionDetector: () => Promise<boolean>;
7
- setLocationUpdateInterval: (ms?: number) => any;
8
- fireGeofenceAlert: (type: string, userName: string) => Promise<boolean>;
9
- fireGenericAlert: (title: string, body: string, id: number) => Promise<boolean>;
10
- cancelGenericAlert: (id: number) => Promise<boolean>;
11
- registerGpsListener: () => Promise<boolean>;
12
- addGpsStatusListener: (cb: (event: {
13
- enabled: boolean;
14
- }) => void) => import("react-native").EventSubscription;
15
- /**
16
- * Returns:
17
- * {
18
- * activity: "WALKING" | "STILL" | "IN_VEHICLE" ...,
19
- * isMoving: boolean,
20
- * state: "MOVING" | "STATIONARY" (Legacy support)
21
- * }
22
- */
23
- addMotionListener: (cb: (event: any) => void) => import("react-native").EventSubscription;
24
- /**
25
- * Returns:
26
- * {
27
- * latitude: number,
28
- * longitude: number,
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 startMotionDetector(confidence: number): Promise<boolean>;
21
+ export declare function stopMotionDetector(): Promise<boolean>;
22
+ export declare function setLocationUpdateInterval(intervalMs: number): Promise<void>;
23
+ export default GeoActivityKit;
37
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":";oCAsBkC,MAAM,QAAQ,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC;iCAG5C,OAAO,CAAC,OAAO,CAAC;uCAGR,MAAM,QAAQ,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC;sCAKzC,MAAM,KAAS,OAAO,CAAC,OAAO,CAAC;8BAGxC,OAAO,CAAC,OAAO,CAAC;qCAIR,MAAM;8BAIZ,MAAM,YAAY,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC;8BAG3C,MAAM,QAAQ,MAAM,MAAM,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC;6BA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AAED,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3E;AAED,eAAe,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-geo-activity-kit",
3
- "version": "1.2.5",
3
+ "version": "2.0.1",
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,13 @@
1
- import { NativeModules, NativeEventEmitter } from 'react-native';
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
- const RNSensorModule = NativeModules.RNSensorModule
9
- ? NativeModules.RNSensorModule
9
+ const GeoActivityKit = NativeModules.GeoActivityKit
10
+ ? NativeModules.GeoActivityKit
10
11
  : new Proxy(
11
12
  {},
12
13
  {
@@ -16,73 +17,53 @@ const RNSensorModule = NativeModules.RNSensorModule
16
17
  }
17
18
  );
18
19
 
19
- const emitter = new NativeEventEmitter(RNSensorModule);
20
-
21
- export default {
22
- // --- SERVICE CONTROL ---
23
- startForegroundService: (title: string, body: string): Promise<boolean> =>
24
- RNSensorModule.startForegroundService(title, body),
25
-
26
- stopForegroundService: (): Promise<boolean> =>
27
- RNSensorModule.stopForegroundService(),
28
-
29
- updateServiceNotification: (title: string, body: string): Promise<boolean> =>
30
- RNSensorModule.updateServiceNotification(title, body),
31
-
32
- // --- MOTION DETECTION (ACTIVITY RECOGNITION) ---
33
- // Note: Threshold is ignored by the new native engine, but kept for compatibility
34
- startMotionDetector: (threshold: number = 0.8): Promise<boolean> =>
35
- RNSensorModule.startMotionDetector(threshold),
36
-
37
- stopMotionDetector: (): Promise<boolean> =>
38
- RNSensorModule.stopMotionDetector(),
39
-
40
- // --- LOCATION CONTROL ---
41
- setLocationUpdateInterval: (ms: number = 90000) =>
42
- RNSensorModule.setLocationUpdateInterval(ms),
43
-
44
- // --- ALERTS ---
45
- fireGeofenceAlert: (type: string, userName: string): Promise<boolean> =>
46
- RNSensorModule.fireGeofenceAlert(type, userName),
47
-
48
- fireGenericAlert: (title: string, body: string, id: number): Promise<boolean> =>
49
- RNSensorModule.fireGenericAlert(title, body, id),
50
-
51
- cancelGenericAlert: (id: number): Promise<boolean> =>
52
- RNSensorModule.cancelGenericAlert(id),
53
-
54
- // --- GPS STATUS ---
55
- registerGpsListener: (): Promise<boolean> =>
56
- RNSensorModule.registerGpsListener(),
57
-
58
- addGpsStatusListener: (cb: (event: { enabled: boolean }) => void) =>
59
- emitter.addListener('onGpsStatusChanged', (event: any) => cb(event)),
60
-
61
- // --- EVENT LISTENERS ---
62
-
63
- /**
64
- * Returns:
65
- * {
66
- * activity: "WALKING" | "STILL" | "IN_VEHICLE" ...,
67
- * isMoving: boolean,
68
- * state: "MOVING" | "STATIONARY" (Legacy support)
69
- * }
70
- */
71
- addMotionListener: (cb: (event: any) => void) =>
72
- emitter.addListener('onMotionStateChanged', cb),
73
-
74
- /**
75
- * Returns:
76
- * {
77
- * latitude: number,
78
- * longitude: number,
79
- * accuracy: number,
80
- * is_mock: boolean (NEW: Detects Fake GPS)
81
- * }
82
- */
83
- addLocationLogListener: (cb: (event: any) => void) =>
84
- emitter.addListener('onLocationLog', cb),
85
-
86
- addLocationErrorListener: (cb: (event: any) => void) =>
87
- emitter.addListener('onLocationError', cb),
88
- };
20
+ export interface LocationEvent {
21
+ latitude: number;
22
+ longitude: number;
23
+ accuracy: number;
24
+ timestamp: string;
25
+ is_mock: boolean;
26
+ }
27
+
28
+ export interface MotionEvent {
29
+ activity:
30
+ | 'STILL'
31
+ | 'WALKING'
32
+ | 'RUNNING'
33
+ | 'ON_BICYCLE'
34
+ | 'IN_VEHICLE'
35
+ | 'UNKNOWN';
36
+ isMoving: boolean;
37
+ state: 'MOVING' | 'STATIONARY';
38
+ }
39
+
40
+ export interface ErrorEvent {
41
+ error: string;
42
+ message: string;
43
+ }
44
+
45
+ export function startForegroundService(
46
+ title: string,
47
+ body: string,
48
+ id: number
49
+ ): Promise<boolean> {
50
+ return GeoActivityKit.startForegroundService(title, body, id);
51
+ }
52
+
53
+ export function stopForegroundService(): Promise<boolean> {
54
+ return GeoActivityKit.stopForegroundService();
55
+ }
56
+
57
+ export function startMotionDetector(confidence: number): Promise<boolean> {
58
+ return GeoActivityKit.startMotionDetector(confidence);
59
+ }
60
+
61
+ export function stopMotionDetector(): Promise<boolean> {
62
+ return GeoActivityKit.stopMotionDetector();
63
+ }
64
+
65
+ export function setLocationUpdateInterval(intervalMs: number): Promise<void> {
66
+ return GeoActivityKit.setLocationUpdateInterval(intervalMs);
67
+ }
68
+
69
+ export default GeoActivityKit;