react-native-geo-activity-kit 2.0.3 → 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.
@@ -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,47 @@
1
1
  "use strict";
2
2
 
3
- import { NativeModules, Platform } from 'react-native';
3
+ import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
4
+ // ✅ Fixed: Modern Type & Correct Import
5
+
4
6
  const LINKING_ERROR = `The package 'react-native-geo-activity-kit' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
5
7
  ios: "- You have run 'pod install'\n",
6
8
  default: ''
7
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
8
12
  const GeoActivityKit = NativeModules.GeoActivityKit ? NativeModules.GeoActivityKit : new Proxy({}, {
9
13
  get() {
10
14
  throw new Error(LINKING_ERROR);
11
15
  }
12
16
  });
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;
17
+ const emitter = new NativeEventEmitter(GeoActivityKit);
18
+
19
+ // 2. Define Types
20
+
21
+ // 3. Export the Object
22
+ export default {
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
+
42
+ addGpsStatusListener: cb => emitter.addListener('onGpsStatusChanged', event => cb(event)),
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))
46
+ };
29
47
  //# 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","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,CAAC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DY,kBAAkB,EAAGZ,EAAU,IAC7BR,cAAc,CAACoB,kBAAkB,CAACZ,EAAE,CAAC;EAEvC;EACAa,mBAAmB,EAAEA,CAAA,KACnBrB,cAAc,CAACqB,mBAAmB,CAAC,CAAC;EAEtC;EACA;EACA;;EAEAC,oBAAoB,EAAGC,EAAyC,IAC9DnB,OAAO,CAACoB,WAAW,CAAC,oBAAoB,EAAGC,KAAU,IAAKF,EAAE,CAACE,KAAK,CAAC,CAAC;EAEtEC,iBAAiB,EAAGH,EAAgC,IAClDnB,OAAO,CAACoB,WAAW,CAAC,sBAAsB,EAAGC,KAAU,IAAKF,EAAE,CAACE,KAAK,CAAC,CAAC;EAExEE,sBAAsB,EAAGJ,EAAkC,IACzDnB,OAAO,CAACoB,WAAW,CAAC,eAAe,EAAGC,KAAU,IAAKF,EAAE,CAACE,KAAK,CAAC,CAAC;EAEjEG,wBAAwB,EAAGL,EAA+B,IACxDnB,OAAO,CAACoB,WAAW,CAAC,iBAAiB,EAAGC,KAAU,IAAKF,EAAE,CAACE,KAAK,CAAC;AACpE,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- declare const GeoActivityKit: any;
1
+ import type { EventSubscription } from 'react-native';
2
2
  export interface LocationEvent {
3
3
  latitude: number;
4
4
  longitude: number;
@@ -15,10 +15,23 @@ export interface ErrorEvent {
15
15
  error: string;
16
16
  message: string;
17
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;
18
+ declare const _default: {
19
+ startForegroundService: (title: string, body: string, id: number) => Promise<boolean>;
20
+ stopForegroundService: () => Promise<boolean>;
21
+ updateServiceNotification: (title: string, body: string) => Promise<boolean>;
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>;
28
+ registerGpsListener: () => Promise<boolean>;
29
+ addGpsStatusListener: (cb: (event: {
30
+ enabled: boolean;
31
+ }) => void) => EventSubscription;
32
+ addMotionListener: (cb: (event: MotionEvent) => void) => EventSubscription;
33
+ addLocationLogListener: (cb: (event: LocationEvent) => void) => EventSubscription;
34
+ addLocationErrorListener: (cb: (event: ErrorEvent) => void) => EventSubscription;
35
+ };
36
+ export default _default;
24
37
  //# 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,O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AAM,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",
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,4 +1,5 @@
1
- import { NativeModules, Platform } 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,6 +7,7 @@ const LINKING_ERROR =
6
7
  '- You rebuilt the app after installing the package\n' +
7
8
  '- You are not using Expo Go\n';
8
9
 
10
+ // 1. Point to the CORRECT Native Module Name
9
11
  const GeoActivityKit = NativeModules.GeoActivityKit
10
12
  ? NativeModules.GeoActivityKit
11
13
  : new Proxy(
@@ -17,6 +19,9 @@ const GeoActivityKit = NativeModules.GeoActivityKit
17
19
  }
18
20
  );
19
21
 
22
+ const emitter = new NativeEventEmitter(GeoActivityKit);
23
+
24
+ // 2. Define Types
20
25
  export interface LocationEvent {
21
26
  latitude: number;
22
27
  longitude: number;
@@ -26,13 +31,7 @@ export interface LocationEvent {
26
31
  }
27
32
 
28
33
  export interface MotionEvent {
29
- activity:
30
- | 'STILL'
31
- | 'WALKING'
32
- | 'RUNNING'
33
- | 'ON_BICYCLE'
34
- | 'IN_VEHICLE'
35
- | 'UNKNOWN';
34
+ activity: 'STILL' | 'WALKING' | 'RUNNING' | 'ON_BICYCLE' | 'IN_VEHICLE' | 'UNKNOWN';
36
35
  isMoving: boolean;
37
36
  state: 'MOVING' | 'STATIONARY';
38
37
  }
@@ -42,28 +41,56 @@ export interface ErrorEvent {
42
41
  message: string;
43
42
  }
44
43
 
45
- export function startForegroundService(
46
- title: string,
47
- body: string,
48
- id: number
49
- ): Promise<boolean> {
50
- return GeoActivityKit.startForegroundService(title, body, id);
51
- }
44
+ // 3. Export the Object
45
+ export default {
46
+ // --- Service Control ---
47
+ startForegroundService: (title: string, body: string, id: number): Promise<boolean> =>
48
+ GeoActivityKit.startForegroundService(title, body, id),
52
49
 
53
- export function stopForegroundService(): Promise<boolean> {
54
- return GeoActivityKit.stopForegroundService();
55
- }
50
+ stopForegroundService: (): Promise<boolean> =>
51
+ GeoActivityKit.stopForegroundService(),
56
52
 
57
- export function startMotionDetector(confidence: number): Promise<boolean> {
58
- return GeoActivityKit.startMotionDetector(confidence);
59
- }
53
+ updateServiceNotification: (title: string, body: string): Promise<boolean> =>
54
+ GeoActivityKit.updateServiceNotification(title, body),
60
55
 
61
- export function stopMotionDetector(): Promise<boolean> {
62
- return GeoActivityKit.stopMotionDetector();
63
- }
56
+ // --- Motion & Intelligence ---
57
+ startMotionDetector: (confidence: number = 75): Promise<boolean> =>
58
+ GeoActivityKit.startMotionDetector(confidence),
64
59
 
65
- export function setLocationUpdateInterval(intervalMs: number): Promise<void> {
66
- return GeoActivityKit.setLocationUpdateInterval(intervalMs);
67
- }
60
+ stopMotionDetector: (): Promise<boolean> =>
61
+ GeoActivityKit.stopMotionDetector(),
62
+
63
+ // --- Location Control ---
64
+ setLocationUpdateInterval: (ms: number): Promise<void> =>
65
+ GeoActivityKit.setLocationUpdateInterval(ms),
66
+
67
+ // --- Alerts & Notifications ---
68
+ fireGeofenceAlert: (type: 'IN' | 'OUT', userName: string): Promise<boolean> =>
69
+ GeoActivityKit.fireGeofenceAlert(type, userName),
70
+
71
+ fireGenericAlert: (title: string, body: string, id: number): Promise<boolean> =>
72
+ GeoActivityKit.fireGenericAlert(title, body, id),
73
+
74
+ cancelGenericAlert: (id: number): Promise<boolean> =>
75
+ GeoActivityKit.cancelGenericAlert(id),
76
+
77
+ // --- GPS Status ---
78
+ registerGpsListener: (): Promise<boolean> =>
79
+ GeoActivityKit.registerGpsListener(),
80
+
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 =>
86
+ emitter.addListener('onGpsStatusChanged', (event: any) => cb(event)),
87
+
88
+ addMotionListener: (cb: (event: MotionEvent) => void): EventSubscription =>
89
+ emitter.addListener('onMotionStateChanged', (event: any) => cb(event)),
90
+
91
+ addLocationLogListener: (cb: (event: LocationEvent) => void): EventSubscription =>
92
+ emitter.addListener('onLocationLog', (event: any) => cb(event)),
68
93
 
69
- export default GeoActivityKit;
94
+ addLocationErrorListener: (cb: (event: ErrorEvent) => void): EventSubscription =>
95
+ emitter.addListener('onLocationError', (event: any) => cb(event)),
96
+ };