transistorsoft / react-native-background-geolocation

Sophisticated, battery-conscious background-geolocation with motion-detection
http://shop.transistorsoft.com/pages/react-native-background-geolocation
MIT License
2.58k stars 425 forks source link

Continuous Location updates not received when moved out of stationary position #1765

Closed GuptaAman08 closed 11 months ago

GuptaAman08 commented 11 months ago

Your Environment

Expected Behavior

Should start sending continuous location updates, when moved a sufficient distance from last stationary point.

Actual Behavior

The react-native application does not automatically start tracking when previously it was in a stationary state for more then 40 minutes. I tried with different distances, ranging from 200 to 2000 meters when trying to resume the tracking from the stationary state. But still, only the first location update is received in the case of Android. Instead, it should start tracking and sending location updates thereafter.

Also, would like to ask one question. Since tried to find all docs but couldn't find them. 1. Suppose, if I don't want to give physical activity permission, then how does the SDK detects that the device is in motion after being in a stationary state irrespective of the time?

Steps to Reproduce

  1. Initialise the plugin
  2. Call the SDK Start Tracking method.
  3. Perform 1-2 random locations updates
  4. Stop moving and be in this state for at least 30-40 mins
  5. Start moving again.
  6. Only one location update is received

Context

Testing when app is in stationary position for 30-40 mins and resuming the tracking

Debug logs

Logs ``` 07-27 19:38:59.124 11285 11285 I TSLocationManager: [c.t.l.service.TrackingService performStopDetection] 07-27 19:38:59.124 11285 11285 I TSLocationManager: ℹ️ Distance from stoppedAtLocation: -10.0 07-27 19:38:59.124 11285 14766 I TSLocationManager: [c.t.l.l.TSLocationManager onLocationResult] 07-27 19:38:59.124 11285 14766 I TSLocationManager: πŸ”΅ Re-scaled distanceFilter: 20.0->60.0) 07-27 19:38:59.130 11285 14965 I TSLocationManager: [c.t.l.http.HttpService a] 07-27 19:38:59.130 11285 14965 I TSLocationManager: πŸ”΅ HTTP POST: 70d8e0cb-da3d-429f-943a-50b0fd654d98 07-27 19:38:59.143 11285 11285 I TSLocationManager: [c.t.l.service.TrackingService performStopDetection] 07-27 19:38:59.143 11285 11285 I TSLocationManager: ℹ️ Distance from stoppedAtLocation: -10.0 07-27 19:38:59.471 11285 15034 I TSLocationManager: [c.t.l.http.HttpService$h onResponse] 07-27 19:38:59.471 11285 15034 I TSLocationManager: πŸ”΅ Response: 200 07-27 19:38:59.476 11285 11375 I ReactNativeJS: 2023-07-27T14:08:59.474Z: onHttp Event {"responseText":"{\"success\":true,\"arrived\":false,\"stop\":false,\"geofences\":[{\"name\":\"NearBy\",\"type\":\"nearby\",\"lastUpdatedAt\":\"2023-07-27T13:33:44.215Z\"},{\"name\":\"proximity_sdk_test-AtLocation\",\"type\":\"at-location\",\"lastUpdatedAt\":\"2023-07-27T14:08:27.251Z\"}],\"orderExternalId\":\"26Jul_04\"}","status":200,"success":true} 07-27 19:38:59.476 11285 11375 I ReactNativeJS: 2023-07-27T14:08:59.476Z: New Geofence Events [] 07-27 19:38:59.482 11285 15034 I TSLocationManager: [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 104 07-27 19:39:04.046 11285 11285 I TSLocationManager: [c.t.l.service.TrackingService performStopDetection] 07-27 19:39:04.046 11285 11285 I TSLocationManager: ℹ️ Distance from stoppedAtLocation: 52.356495 07-27 19:39:04.049 11285 11285 I TSLocationManager: [c.t.l.s.TSScheduleManager cancelOneShot] 07-27 19:39:04.049 11285 11285 I TSLocationManager: ⏰ Cancel OneShot: STOP_TIMEOUT 07-27 19:39:04.050 11285 14766 I TSLocationManager: [c.t.l.data.sqlite.b persist] 07-27 19:39:04.050 11285 14766 I TSLocationManager: βœ… INSERT: 2d35e920-da0f-424c-b4c2-e1d58cd056e4 07-27 19:39:04.054 11285 11285 I TSLocationManager: [c.t.l.s.TSScheduleManager oneShot] 07-27 19:39:04.054 11285 11285 I TSLocationManager: ⏰ Scheduled OneShot: MOTION_ACTIVITY_CHECK in 64941ms (jobID: -18513055) 07-27 19:39:04.057 11285 14766 I TSLocationManager: [c.t.l.http.HttpService flush] 07-27 19:39:04.057 11285 14766 I TSLocationManager: ╔═════════════════════════════════════════════ 07-27 19:39:04.057 11285 14766 I TSLocationManager: β•‘ HTTP Service (count: 1) 07-27 19:39:04.057 11285 14766 I TSLocationManager: ╠═════════════════════════════════════════════ 07-27 19:39:04.069 11285 11285 I TSLocationManager: [c.t.l.u.BackgroundTaskManager$Task start] ⏳ startBackgroundTask: 105 07-27 19:39:04.074 11285 14766 I TSLocationManager: [c.t.l.http.HttpService a] 07-27 19:39:04.074 11285 14766 I TSLocationManager: πŸ”΅ HTTP POST: 2d35e920-da0f-424c-b4c2-e1d58cd056e4 07-27 19:39:04.406 11285 15034 I TSLocationManager: [c.t.l.http.HttpService$h onResponse] 07-27 19:39:04.406 11285 15034 I TSLocationManager: πŸ”΅ Response: 200 07-27 19:39:04.411 11285 11375 I ReactNativeJS: 2023-07-27T14:09:04.409Z: onHttp Event {"responseText":"{\"success\":true,\"arrived\":false,\"stop\":false,\"geofences\":[{\"name\":\"NearBy\",\"type\":\"nearby\",\"lastUpdatedAt\":\"2023-07-27T13:33:44.215Z\"},{\"name\":\"proximity_sdk_test-AtLocation\",\"type\":\"at-location\",\"lastUpdatedAt\":\"2023-07-27T14:08:27.251Z\"}],\"orderExternalId\":\"26Jul_04\"}","status":200,"success":true} 07-27 19:39:04.414 11285 11375 I ReactNativeJS: 2023-07-27T14:09:04.413Z: New Geofence Events [] 07-27 19:39:04.418 11285 15034 I TSLocationManager: [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 105 07-27 19:40:12.249 11285 15126 I TSLocationManager: [c.t.l.scheduler.ScheduleEvent onOneShot] 07-27 19:40:12.249 11285 15126 I TSLocationManager: ╔═════════════════════════════════════════════ 07-27 19:40:12.249 11285 15126 I TSLocationManager: β•‘ ⏰ OneShot event fired: MOTION_ACTIVITY_CHECK 07-27 19:40:12.249 11285 15126 I TSLocationManager: ╠═════════════════════════════════════════════ 07-27 19:40:12.251 11285 11285 I TSLocationManager: [c.t.l.s.ActivityRecognitionService start] 07-27 19:40:12.251 11285 11285 I TSLocationManager: 🎾 Start motion-activity updates 07-27 19:40:12.796 11285 11285 I TSLocationManager: [c.t.l.s.TSScheduleManager oneShot] 07-27 19:40:12.796 11285 11285 I TSLocationManager: ⏰ Scheduled OneShot: STOP_TIMEOUT in 1200000ms (jobID: 2059034116) 07-27 19:40:12.799 11285 11285 I TSLocationManager: [c.t.l.l.TSLocationManager removeLocationUpdates] 07-27 19:40:12.799 11285 11285 I TSLocationManager: πŸ”΄ Location-services: OFF 07-27 19:40:12.800 11285 11285 I TSLocationManager: [c.t.l.l.TSLocationManager requestLocationUpdates] 07-27 19:40:12.800 11285 11285 I TSLocationManager: 🎾 Location-services: ON 07-27 19:40:17.353 11285 15126 I TSLocationManager: [c.t.l.l.TSLocationManager onLocationResult] 07-27 19:40:17.353 11285 15126 I TSLocationManager: πŸ”΅ Re-scaled distanceFilter: 20.0->60.0) 07-27 19:40:17.353 11285 11285 I TSLocationManager: [c.t.l.service.TrackingService performStopDetection] 07-27 19:40:17.353 11285 11285 I TSLocationManager: ℹ️ Distance from stoppedAtLocation: -10.0 07-27 19:40:17.396 11285 15251 I TSLocationManager: [c.t.l.data.sqlite.b persist] 07-27 19:40:17.396 11285 15251 I TSLocationManager: βœ… INSERT: 850a437c-486c-4fb8-bfcd-fcac0439072b 07-27 19:40:17.408 11285 15251 I TSLocationManager: [c.t.l.http.HttpService flush] 07-27 19:40:17.408 11285 15251 I TSLocationManager: ╔═════════════════════════════════════════════ 07-27 19:40:17.408 11285 15251 I TSLocationManager: β•‘ HTTP Service (count: 1) 07-27 19:40:17.408 11285 15251 I TSLocationManager: ╠═════════════════════════════════════════════ 07-27 19:40:17.414 11285 11285 I TSLocationManager: [c.t.l.service.TrackingService performStopDetection] 07-27 19:40:17.414 11285 11285 I TSLocationManager: ℹ️ Distance from stoppedAtLocation: -10.0 07-27 19:40:17.425 11285 11285 I TSLocationManager: [c.t.l.u.BackgroundTaskManager$Task start] ⏳ startBackgroundTask: 106 07-27 19:40:17.443 11285 15251 I TSLocationManager: [c.t.l.http.HttpService a] 07-27 19:40:17.443 11285 15251 I TSLocationManager: πŸ”΅ HTTP POST: 850a437c-486c-4fb8-bfcd-fcac0439072b 07-27 19:40:17.763 11285 15252 I TSLocationManager: [c.t.l.http.HttpService$h onResponse] 07-27 19:40:17.763 11285 15252 I TSLocationManager: πŸ”΅ Response: 200 07-27 19:40:17.768 11285 11375 I ReactNativeJS: 2023-07-27T14:10:17.766Z: onHttp Event {"responseText":"{\"success\":true,\"arrived\":false,\"stop\":false,\"geofences\":[{\"name\":\"NearBy\",\"type\":\"nearby\",\"lastUpdatedAt\":\"2023-07-27T13:33:44.215Z\"},{\"name\":\"proximity_sdk_test-AtLocation\",\"type\":\"at-location\",\"lastUpdatedAt\":\"2023-07-27T14:08:27.251Z\"}],\"orderExternalId\":\"26Jul_04\"}","status":200,"success":true} 07-27 19:40:17.769 11285 11375 I ReactNativeJS: 2023-07-27T14:10:17.769Z: New Geofence Events [] 07-27 19:40:17.774 11285 15252 I TSLocationManager: [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 106 07-27 20:00:12.840 11285 16266 I TSLocationManager: [c.t.l.scheduler.ScheduleEvent onOneShot] 07-27 20:00:12.840 11285 16266 I TSLocationManager: ╔═════════════════════════════════════════════ 07-27 20:00:12.840 11285 16266 I TSLocationManager: β•‘ ⏰ OneShot event fired: STOP_TIMEOUT 07-27 20:00:12.840 11285 16266 I TSLocationManager: ╠═════════════════════════════════════════════ 07-27 20:00:12.876 11285 16266 I TSLocationManager: [c.t.l.service.HeartbeatService start] 07-27 20:00:12.876 11285 16266 I TSLocationManager: 🎾 Start heartbeat (60s) 07-27 20:00:12.886 11285 16266 I TSLocationManager: [c.t.l.l.TSLocationManager removeLocationUpdates] 07-27 20:00:12.886 11285 16266 I TSLocationManager: πŸ”΄ Location-services: OFF 07-27 20:00:12.896 11285 16266 I TSLocationManager: [c.t.l.service.TrackingService changePace] 07-27 20:00:12.896 11285 16266 I TSLocationManager: πŸ”΅ setPace: true β†’ false 07-27 20:00:12.911 11285 16266 I TSLocationManager: [c.t.l.l.SingleLocationRequest startUpdatingLocation] 07-27 20:00:12.911 11285 16266 I TSLocationManager: πŸ”΅ [SingleLocationRequest start, action: 1, requestId: 11] 07-27 20:00:12.912 11285 16266 I TSLocationManager: [c.t.l.s.ActivityRecognitionService start] 07-27 20:00:12.912 11285 16266 I TSLocationManager: 🎾 Start motion-activity updates 07-27 20:00:13.009 11285 16266 I TSLocationManager: [c.t.l.s.LocationRequestService handleLocationAvailability] 07-27 20:00:13.009 11285 16266 I TSLocationManager: ℹ️ Location availability: true 07-27 20:00:16.545 11285 16266 I TSLocationManager: [c.t.l.s.LocationRequestService handleLocationResult] 07-27 20:00:16.545 11285 16266 I TSLocationManager: ╔═════════════════════════════════════════════ 07-27 20:00:16.545 11285 16266 I TSLocationManager: β•‘ motionchange LocationResult: 11 07-27 20:00:16.545 11285 16266 I TSLocationManager: ╠═════════════════════════════════════════════ 07-27 20:00:16.545 11285 16266 I TSLocationManager: β•Ÿβ”€ πŸ“ Location[fused 18.972117,72.809457 hAcc=5 et=+2h21m49s816ms alt=0.0 vel=27.131777 bear=173.0 vAcc=1 sAcc=1 bAcc=30 {Bundle[mParcelledData.dataSize=52]}], age: 14ms, time: 1690468216526 07-27 20:00:16.546 11285 16266 I TSLocationManager: [c.t.l.l.TSLocationManager onSingleLocationResult] 07-27 20:00:16.546 11285 16266 I TSLocationManager: πŸ”΅ Acquired motionchange position, isMoving: false 07-27 20:00:16.558 11285 16277 I TSLocationManager: [c.t.l.data.sqlite.b persist] 07-27 20:00:16.558 11285 16277 I TSLocationManager: βœ… INSERT: 7063fbb6-5511-4d85-bf4b-e23522180e5f 07-27 20:00:16.573 11285 11285 I TSLocationManager: [c.t.l.service.TrackingService handleMotionChangeResult] 07-27 20:00:16.573 11285 11285 I TSLocationManager: ╔═════════════════════════════════════════════ 07-27 20:00:16.573 11285 11285 I TSLocationManager: β•‘ TrackingService motionchange: false 07-27 20:00:16.573 11285 11285 I TSLocationManager: ╠═════════════════════════════════════════════ 07-27 20:00:16.574 11285 16277 I TSLocationManager: [c.t.l.http.HttpService flush] 07-27 20:00:16.574 11285 16277 I TSLocationManager: ╔═════════════════════════════════════════════ 07-27 20:00:16.574 11285 16277 I TSLocationManager: β•‘ HTTP Service (count: 1) 07-27 20:00:16.574 11285 16277 I TSLocationManager: ╠═════════════════════════════════════════════ 07-27 20:00:16.585 11285 11285 I TSLocationManager: [c.t.l.u.BackgroundTaskManager$Task start] ⏳ startBackgroundTask: 107 07-27 20:00:16.592 11285 16277 I TSLocationManager: [c.t.l.http.HttpService a] 07-27 20:00:16.592 11285 16277 I TSLocationManager: πŸ”΅ HTTP POST: 7063fbb6-5511-4d85-bf4b-e23522180e5f 07-27 20:00:17.729 11285 16278 I TSLocationManager: [c.t.l.http.HttpService$h onResponse] 07-27 20:00:17.729 11285 16278 I TSLocationManager: πŸ”΅ Response: 200 07-27 20:00:17.740 11285 16278 I TSLocationManager: [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 107 07-27 20:00:17.744 11285 11375 I ReactNativeJS: 2023-07-27T14:30:17.737Z: onHttp Event {"responseText":"{\"success\":true,\"arrived\":false,\"stop\":false,\"geofences\":[{\"name\":\"NearBy\",\"type\":\"nearby\",\"lastUpdatedAt\":\"2023-07-27T13:33:44.215Z\"},{\"name\":\"proximity_sdk_test-AtLocation\",\"type\":\"at-location\",\"lastUpdatedAt\":\"2023-07-27T14:08:27.251Z\"}],\"orderExternalId\":\"26Jul_04\"}","status":200,"success":true} 07-27 20:00:17.747 11285 11375 I ReactNativeJS: 2023-07-27T14:30:17.746Z: New Geofence Events [] 07-27 20:05:40.298 11285 11285 I TSLocationManager: [c.t.l.s.TSScheduleManager oneShot] 07-27 20:05:40.298 11285 11285 I TSLocationManager: ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588) 07-27 20:05:50.327 11285 16550 I TSLocationManager: [c.t.l.scheduler.ScheduleEvent onOneShot] 07-27 20:05:50.327 11285 16550 I TSLocationManager: ╔═════════════════════════════════════════════ 07-27 20:05:50.327 11285 16550 I TSLocationManager: β•‘ ⏰ OneShot event fired: TERMINATE_EVENT 07-27 20:05:50.327 11285 16550 I TSLocationManager: ╠═════════════════════════════════════════════ 07-27 20:06:03.395 11285 16550 I TSLocationManager: [c.t.l.http.HttpService flush] 07-27 20:06:03.395 11285 16550 I TSLocationManager: ╔═════════════════════════════════════════════ 07-27 20:06:03.395 11285 16550 I TSLocationManager: β•‘ HTTP Service (count: 0) 07-27 20:06:03.395 11285 16550 I TSLocationManager: ╠═════════════════════════════════════════════ 07-27 20:06:24.140 11285 11285 I TSLocationManager: [c.t.l.s.TSScheduleManager oneShot] 07-27 20:06:24.140 11285 11285 I TSLocationManager: ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588) 07-27 20:06:34.171 11285 16550 I TSLocationManager: [c.t.l.scheduler.ScheduleEvent onOneShot] 07-27 20:06:34.171 11285 16550 I TSLocationManager: ╔═════════════════════════════════════════════ 07-27 20:06:34.171 11285 16550 I TSLocationManager: β•‘ ⏰ OneShot event fired: TERMINATE_EVENT 07-27 20:06:34.171 11285 16550 I TSLocationManager: ╠═════════════════════════════════════════════ 07-27 20:07:44.107 11285 16550 I TSLocationManager: [c.t.l.http.HttpService flush] 07-27 20:07:44.107 11285 16550 I TSLocationManager: ╔═════════════════════════════════════════════ 07-27 20:07:44.107 11285 16550 I TSLocationManager: β•‘ HTTP Service (count: 0) 07-27 20:07:44.107 11285 16550 I TSLocationManager: ╠═════════════════════════════════════════════ ```
christocracy commented 11 months ago

Device manufacturer / model: Android Emulator

Geofences don’t work in the Emulator. The plug-in cannot automatically trigger location-tracking in the Emulator, only in a real device with real movement.

GuptaAman08 commented 11 months ago

Geofences don’t work in the Emulator. The plug-in cannot automatically trigger location-tracking in the Emulator, only in a real device with real movement.

FYI, am using the built-in Android emulator journey spoofer. So, as per what you are saying if your sdk detects a device in motion when I use startTracking(), then traveling a sufficient amount of distance post being in the stationary state should also trigger right ??

Also, can you please answer the below question? Since it can be a use case where users don't allow this permission. In the case of iOS its clear, but Android its being unclear

Suppose, if I don't want to give physical activity permission, then how does the SDK detect that the device is in motion after being in a stationary state irrespective of the time?

christocracy commented 11 months ago

where users don't allow this permission. In the case of iOS its clear, but Android its being unclear

Android uses a β€œstationary geofence” (just like iOS) as a backup. The Android plug-in operates under the assumption that the User will reject Motion permission.