react-native-geo-activity-kit 2.0.3 → 2.0.4

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.
@@ -38,7 +38,7 @@ class SensorModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
38
38
  }
39
39
 
40
40
  override fun getName(): String {
41
- return "GeoActivityKit"
41
+ return "RNSensorModule"
42
42
  }
43
43
 
44
44
  init {
@@ -1,29 +1,35 @@
1
1
  "use strict";
2
2
 
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({}, {
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({}, {
9
6
  get() {
10
7
  throw new Error(LINKING_ERROR);
11
8
  }
12
9
  });
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;
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
+ // Sensors & Configuration
17
+ startMotionDetector: (threshold = 0.8) => RNSensorModule.startMotionDetector(threshold),
18
+ stopMotionDetector: () => RNSensorModule.stopMotionDetector(),
19
+ setUpdateInterval: (ms = 100) => RNSensorModule.setUpdateInterval(ms),
20
+ setLocationUpdateInterval: (ms = 90000) => RNSensorModule.setLocationUpdateInterval(ms),
21
+ setStabilityThresholds: (start = 20, stop = 3000) => RNSensorModule.setStabilityThresholds(start, stop),
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
+ isAvailable: () => RNSensorModule.isAvailable(),
27
+ // --- NEW GPS HARDWARE METHODS ---
28
+ registerGpsListener: () => RNSensorModule.registerGpsListener(),
29
+ addGpsStatusListener: cb => emitter.addListener('onGpsStatusChanged', event => cb(event)),
30
+ // Listeners
31
+ addMotionListener: cb => emitter.addListener('onMotionStateChanged', cb),
32
+ addLocationLogListener: cb => emitter.addListener('onLocationLog', cb),
33
+ addLocationErrorListener: cb => emitter.addListener('onLocationError', cb)
34
+ };
29
35
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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
+ {"version":3,"names":["NativeModules","NativeEventEmitter","LINKING_ERROR","RNSensorModule","Proxy","get","Error","emitter","startForegroundService","title","body","stopForegroundService","updateServiceNotification","startMotionDetector","threshold","stopMotionDetector","setUpdateInterval","ms","setLocationUpdateInterval","setStabilityThresholds","start","stop","fireGeofenceAlert","type","userName","fireGenericAlert","id","cancelGenericAlert","isAvailable","registerGpsListener","addGpsStatusListener","cb","addListener","event","addMotionListener","addLocationLogListener","addLocationErrorListener"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,kBAAkB,QAAQ,cAAc;AAEh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Q,CAAC;EAElDC,gBAAgB,EAAEA,CAAChB,KAAa,EAAEC,IAAY,EAAEgB,EAAU,KACxDvB,cAAc,CAACsB,gBAAgB,CAAChB,KAAK,EAAEC,IAAI,EAAEgB,EAAE,CAAC;EAElDC,kBAAkB,EAAGD,EAAU,IAAKvB,cAAc,CAACwB,kBAAkB,CAACD,EAAE,CAAC;EAEzEE,WAAW,EAAEA,CAAA,KAAMzB,cAAc,CAACyB,WAAW,CAAC,CAAC;EAE/C;EACAC,mBAAmB,EAAEA,CAAA,KACnB1B,cAAc,CAAC0B,mBAAmB,CAAC,CAAC;EAEtCC,oBAAoB,EAAGC,EAAyC,IAC9DxB,OAAO,CAACyB,WAAW,CAAC,oBAAoB,EAAGC,KAAU,IAAKF,EAAE,CAACE,KAAK,CAAC,CAAC;EAEtE;EACAC,iBAAiB,EAAGH,EAAwB,IAC1CxB,OAAO,CAACyB,WAAW,CAAC,sBAAsB,EAAED,EAAE,CAAC;EAEjDI,sBAAsB,EAAGJ,EAAwB,IAC/CxB,OAAO,CAACyB,WAAW,CAAC,eAAe,EAAED,EAAE,CAAC;EAE1CK,wBAAwB,EAAGL,EAAwB,IACjDxB,OAAO,CAACyB,WAAW,CAAC,iBAAiB,EAAED,EAAE;AAC7C,CAAC","ignoreList":[]}
@@ -1,24 +1,23 @@
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;
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) => any;
6
+ stopMotionDetector: () => any;
7
+ setUpdateInterval: (ms?: number) => any;
8
+ setLocationUpdateInterval: (ms?: number) => any;
9
+ setStabilityThresholds: (start?: number, stop?: number) => any;
10
+ fireGeofenceAlert: (type: string, userName: string) => any;
11
+ fireGenericAlert: (title: string, body: string, id: number) => any;
12
+ cancelGenericAlert: (id: number) => any;
13
+ isAvailable: () => any;
14
+ registerGpsListener: () => Promise<boolean>;
15
+ addGpsStatusListener: (cb: (event: {
16
+ enabled: boolean;
17
+ }) => void) => import("react-native").EventSubscription;
18
+ addMotionListener: (cb: (event: any) => void) => import("react-native").EventSubscription;
19
+ addLocationLogListener: (cb: (event: any) => void) => import("react-native").EventSubscription;
20
+ addLocationErrorListener: (cb: (event: any) => void) => import("react-native").EventSubscription;
21
+ };
22
+ export default _default;
24
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAQA,QAAA,MAAM,cAAc,KASf,CAAC;AAEN,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,EACJ,OAAO,GACP,SAAS,GACT,SAAS,GACT,YAAY,GACZ,YAAY,GACZ,SAAS,CAAC;IACd,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;AAED,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,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAExE;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC,CAErD;AAED,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3E;AAED,eAAe,cAAc,CAAC"}
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;sCAIzC,MAAM;;6BAKf,MAAM;qCAEE,MAAM;qCAGN,MAAM,SAAa,MAAM;8BAI/B,MAAM,YAAY,MAAM;8BAGxB,MAAM,QAAQ,MAAM,MAAM,MAAM;6BAGjC,MAAM;;+BAKN,OAAO,CAAC,OAAO,CAAC;+BAGd,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI;4BAIxC,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI;iCAGf,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI;mCAGlB,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI;;AAlDrD,wBAoDE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-geo-activity-kit",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
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,13 +1,12 @@
1
- import { NativeModules, Platform } from 'react-native';
1
+ import { NativeModules, NativeEventEmitter } 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: '' }) +
6
5
  '- You rebuilt the app after installing the package\n' +
7
6
  '- You are not using Expo Go\n';
8
7
 
9
- const GeoActivityKit = NativeModules.GeoActivityKit
10
- ? NativeModules.GeoActivityKit
8
+ const RNSensorModule = NativeModules.RNSensorModule
9
+ ? NativeModules.RNSensorModule
11
10
  : new Proxy(
12
11
  {},
13
12
  {
@@ -17,53 +16,58 @@ const GeoActivityKit = NativeModules.GeoActivityKit
17
16
  }
18
17
  );
19
18
 
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;
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
+ // 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),
39
+
40
+ setLocationUpdateInterval: (ms: number = 90000) =>
41
+ RNSensorModule.setLocationUpdateInterval(ms),
42
+
43
+ setStabilityThresholds: (start: number = 20, stop: number = 3000) =>
44
+ RNSensorModule.setStabilityThresholds(start, stop),
45
+
46
+ // Alerts
47
+ fireGeofenceAlert: (type: string, userName: string) =>
48
+ RNSensorModule.fireGeofenceAlert(type, userName),
49
+
50
+ fireGenericAlert: (title: string, body: string, id: number) =>
51
+ RNSensorModule.fireGenericAlert(title, body, id),
52
+
53
+ cancelGenericAlert: (id: number) => RNSensorModule.cancelGenericAlert(id),
54
+
55
+ isAvailable: () => RNSensorModule.isAvailable(),
56
+
57
+ // --- NEW GPS HARDWARE METHODS ---
58
+ registerGpsListener: (): Promise<boolean> =>
59
+ RNSensorModule.registerGpsListener(),
60
+
61
+ addGpsStatusListener: (cb: (event: { enabled: boolean }) => void) =>
62
+ emitter.addListener('onGpsStatusChanged', (event: any) => cb(event)),
63
+
64
+ // Listeners
65
+ addMotionListener: (cb: (event: any) => void) =>
66
+ emitter.addListener('onMotionStateChanged', cb),
67
+
68
+ addLocationLogListener: (cb: (event: any) => void) =>
69
+ emitter.addListener('onLocationLog', cb),
70
+
71
+ addLocationErrorListener: (cb: (event: any) => void) =>
72
+ emitter.addListener('onLocationError', cb),
73
+ };