react-native-geo-activity-kit 3.0.0 → 3.0.2

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.
@@ -22,15 +22,11 @@ class ActivityTransitionReceiver : BroadcastReceiver() {
22
22
 
23
23
  Log.d("ActivityReceiver", "🏃 Motion Event: $activityType ($transitionType)")
24
24
 
25
- val isMoving = when(event.activityType) {
26
- DetectedActivity.WALKING,
27
- DetectedActivity.RUNNING,
28
- DetectedActivity.ON_BICYCLE,
29
- DetectedActivity.IN_VEHICLE -> true
30
- else -> false
31
- }
25
+ val isMoving = (event.transitionType == com.google.android.gms.location.ActivityTransition.ACTIVITY_TRANSITION_ENTER &&
26
+ (event.activityType == DetectedActivity.WALKING || event.activityType == DetectedActivity.IN_VEHICLE)) ||
27
+ (event.activityType == DetectedActivity.STILL && event.transitionType == com.google.android.gms.location.ActivityTransition.ACTIVITY_TRANSITION_EXIT)
32
28
 
33
- // --- NEW: DIRECT NATIVE CONTROL (No JS required) ---
29
+
34
30
  try {
35
31
  if (isMoving) {
36
32
  // Fast Updates (30s) when moving
@@ -40,8 +40,8 @@ class LocationHelper(private val context: ReactApplicationContext) {
40
40
  // -----------------------
41
41
 
42
42
  locationRequest = LocationRequest.create().apply {
43
- interval = 30000
44
- fastestInterval = 30000
43
+ interval = 300000 // Change from 30000 to 300000 (5 mins)
44
+ fastestInterval = 300000 // Change from 30000 to 300000
45
45
  priority = Priority.PRIORITY_BALANCED_POWER_ACCURACY
46
46
  }
47
47
 
@@ -50,12 +50,14 @@ class SensorModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
50
50
  // --- SERVICE CONTROL ---
51
51
 
52
52
  @ReactMethod
53
- fun startForegroundService(title: String, body: String, promise: Promise) {
53
+ // ADD "id: Int" here. Now it matches JavaScript's 3 arguments.
54
+ fun startForegroundService(title: String, body: String, id: Int, promise: Promise) {
54
55
  try {
55
56
  val intent = Intent(reactApplicationContext, TrackingService::class.java)
56
57
  intent.action = TrackingService.ACTION_START
57
58
  intent.putExtra("title", title)
58
59
  intent.putExtra("body", body)
60
+ // intent.putExtra("id", id) // Optional: Pass it if you want to use it later
59
61
 
60
62
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
61
63
  reactApplicationContext.startForegroundService(intent)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-geo-activity-kit",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
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",