react-native-geo-activity-kit 1.0.0 → 1.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.
Files changed (2) hide show
  1. package/README.md +205 -10
  2. package/package.json +4 -9
package/README.md CHANGED
@@ -1,15 +1,210 @@
1
- # react-native-geo-activity-kit
1
+ # react-native-geo-activity-kit 📍
2
2
 
3
- A battery-efficient background location tracker that uses the accelerometer to stop GPS when the device is stationary. It also includes a built-in notification engine for sticky services and alerts.
3
+ A battery-efficient background location tracker for React Native.
4
+ Most GPS libraries drain your battery in 3 hours. This library lasts 24+ hours.
4
5
 
5
- ## Features
6
+ ---
6
7
 
7
- * **🔋 Battery Efficient:** Automatically toggles GPS off when the device stops moving.
8
- * **🏃 Motion Detection:** Exposes raw motion state ("MOVING" vs "STATIONARY").
9
- * **🔔 Native Notifications:** Built-in engine for local alerts and foreground services.
10
- * **📍 Fused Location:** Uses Google's FusedLocationProvider for high accuracy.
8
+ ## 🧠 How it Works (The "Smart Switch")
11
9
 
12
- ## Installation
10
+ Standard location libraries keep the GPS chip (High Power) active 100% of the time.
11
+ This library uses the **Accelerometer (Low Power)** to act as a smart GPS switch:
13
12
 
14
- ```sh
15
- npm install react-native-geo-activity-kit
13
+ - **User Sits Still:** Accelerometer detects no movement → **GPS OFF 🔴** (Zero Battery Drain)
14
+ - **User Walks/Drives:** Accelerometer detects force → **GPS ON 🟢** (High Accuracy)
15
+
16
+ ---
17
+
18
+ ## 📦 Installation
19
+
20
+ ```
21
+ npm install react-native-geo-activity-kit
22
+ ```
23
+
24
+ or
25
+
26
+ ```
27
+ yarn add react-native-geo-activity-kit
28
+ ```
29
+
30
+ ---
31
+
32
+ ## 🤖 Android Setup (Required)
33
+
34
+ File: `android/app/src/main/AndroidManifest.xml`
35
+ Add this inside `<manifest>`:
36
+
37
+ ```xml
38
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
39
+
40
+ <!-- 1. Location Permissions -->
41
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
42
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
43
+
44
+ <!-- 2. Service Permissions -->
45
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
46
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
47
+
48
+ <!-- 3. Notification Permissions -->
49
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
50
+
51
+ <!-- 4. System Permissions -->
52
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
53
+
54
+ </manifest>
55
+ ```
56
+
57
+ ---
58
+
59
+ ## 🚀 Quick Start Guide
60
+
61
+ ### **Step 1: Ask for Permissions**
62
+
63
+ ```js
64
+ import { PermissionsAndroid, Platform } from 'react-native';
65
+
66
+ const requestPermissions = async () => {
67
+ if (Platform.OS === 'android') {
68
+ await PermissionsAndroid.requestMultiple([
69
+ PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
70
+ PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION,
71
+ PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS,
72
+ ]);
73
+ }
74
+ };
75
+ ```
76
+
77
+ ---
78
+
79
+ ### **Step 2: Start the Tracker**
80
+
81
+ `App.js` Example:
82
+
83
+ ```js
84
+ import React, { useEffect, useState } from 'react';
85
+ import { View, Text, Button } from 'react-native';
86
+ import GeoKit from 'react-native-geo-activity-kit';
87
+
88
+ const App = () => {
89
+ const [status, setStatus] = useState("Unknown");
90
+ const [logs, setLogs] = useState([]);
91
+
92
+ useEffect(() => {
93
+ const motionListener = GeoKit.addMotionListener((event) => {
94
+ console.log("Motion State:", event.state);
95
+ setStatus(event.state);
96
+ });
97
+
98
+ const locListener = GeoKit.addLocationLogListener((loc) => {
99
+ console.log("New Location:", loc.latitude, loc.longitude);
100
+ setLogs(prev => [`${loc.latitude}, ${loc.longitude}`, ...prev]);
101
+ });
102
+
103
+ return () => {
104
+ motionListener.remove();
105
+ locListener.remove();
106
+ };
107
+ }, []);
108
+
109
+ const startTracking = async () => {
110
+ await GeoKit.startMotionDetector(0.8);
111
+ };
112
+
113
+ const stopTracking = () => {
114
+ GeoKit.stopMotionDetector();
115
+ setStatus("Stopped");
116
+ };
117
+
118
+ return (
119
+ <View style={{ padding: 50 }}>
120
+ <Text style={{ fontSize: 20 }}>Status: {status}</Text>
121
+ <Button title="Start Tracking" onPress={startTracking} />
122
+ <Button title="Stop Tracking" color="red" onPress={stopTracking} />
123
+ {logs.map((l, i) => <Text key={i}>{l}</Text>)}
124
+ </View>
125
+ );
126
+ };
127
+
128
+ export default App;
129
+ ```
130
+
131
+ ---
132
+
133
+ ## 🎛️ Configuration Guide
134
+
135
+ ### **1. Motion Sensitivity (threshold)**
136
+ - Controls how much force is needed to detect MOVING.
137
+ - Range: **0.1 (very sensitive) → 2.0 (hard to trigger)**
138
+ - Recommended: **0.8**
139
+
140
+ ### **2. Motion Check Speed (setUpdateInterval)**
141
+ - How often accelerometer checks movement.
142
+ - Default: **100ms**
143
+
144
+ ### **3. False Positive Protection (setStabilityThresholds)**
145
+ - Prevents accidental GPS ON/OFF triggers.
146
+
147
+ Defaults:
148
+ - **Start: 20 checks**
149
+ - **Stop: 3000 checks**
150
+
151
+ ### **4. GPS Frequency (setLocationUpdateInterval)**
152
+ - How often GPS logs when MOVING.
153
+ - Default: **90000 ms (90s)**
154
+
155
+ ---
156
+
157
+ ## 🔔 Native Notifications
158
+
159
+ ```js
160
+ await GeoKit.fireGenericAlert(
161
+ "Shift Ended",
162
+ "Please mark your attendance out.",
163
+ 101
164
+ );
165
+
166
+ await GeoKit.fireGeofenceAlert("IN", "John Doe");
167
+ await GeoKit.fireGeofenceAlert("OUT", "John Doe");
168
+
169
+ await GeoKit.cancelGenericAlert(101);
170
+ ```
171
+
172
+ ---
173
+
174
+ ## 📚 API Reference
175
+
176
+ | Method | Description |
177
+ |--------|-------------|
178
+ | startMotionDetector(threshold) | Starts sensors. |
179
+ | stopMotionDetector() | Stops sensors + GPS. |
180
+ | setUpdateInterval(ms) | Accelerometer interval. |
181
+ | setStabilityThresholds(start, stop) | Samples required to switch states. |
182
+ | setLocationUpdateInterval(ms) | GPS log interval while moving. |
183
+ | fireGenericAlert(title, body, id) | Push notification. |
184
+ | fireGeofenceAlert(type, name) | Enter/Exit notification. |
185
+ | isAvailable() | Check accelerometer availability. |
186
+
187
+ ---
188
+
189
+ ## ❓ Troubleshooting
190
+
191
+ ### **1. Walking but no location logs?**
192
+ - If Motion State = **STATIONARY**, GPS is OFF.
193
+ - Shake the device to trigger MOVING.
194
+
195
+ ### **2. Android 14 Crash?**
196
+ Add:
197
+
198
+ ```xml
199
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
200
+ ```
201
+
202
+ ### **3. Need Physical Activity permission?**
203
+ ❌ **No.**
204
+ Accelerometer does not require the ACTIVITY_RECOGNITION permission.
205
+
206
+ ---
207
+
208
+ ## 📄 License
209
+
210
+ MIT# react-native-geo-activity-kit
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-geo-activity-kit",
3
- "version": "1.0.0",
3
+ "version": "1.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",
@@ -42,13 +42,8 @@
42
42
  },
43
43
  "keywords": [
44
44
  "react-native",
45
- "location",
46
- "geofence",
47
- "background-service",
48
- "motion-detection",
49
- "accelerometer",
50
- "android",
51
- "battery-efficient"
45
+ "ios",
46
+ "android"
52
47
  ],
53
48
  "repository": {
54
49
  "type": "git",
@@ -172,4 +167,4 @@
172
167
  ],
173
168
  "version": "0.55.1"
174
169
  }
175
- }
170
+ }