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.61k stars 428 forks source link

Schedule activating but no location updates being recorded #1950

Closed vonkanehoffen closed 3 months ago

vonkanehoffen commented 6 months ago

Your Environment

Expected Behavior

Location should be recorded between the selected times when the app is inactive

Actual Behavior

According to the logs, the schedule activates, but no location is recorded

Steps to Reproduce

  1. Set a schedule the day before
  2. Reopen the app some time after the schedule window has completed and a journey has been made inside that window
  3. Note no location data has been recorded

Context

Have any journey made by the user inside a chosen timeframe be recorded while the app is not in use.

Note in the logs at 02-19 10:01:23.373 schedule starts, and at 02-19 14:01:00.058 it ends, but in between no meaningful location data is recorded, despite me being in a car with the device navigating via google maps between ~ 10.30 and 11:00.

Also note I have a headless task setup in index.js as follows (which I need for such things to work, right?), however I don't see any log messages from it:

import 'expo-router/entry';

import BackgroundGeolocation from 'react-native-background-geolocation';

const BackgroundGeolocationHeadlessTask = async (event) => {
  const params = event.params;
  console.log('[BackgroundGeolocation HeadlessTask] -', event.name, params);

  let location;
  switch (event.name) {
    case 'heartbeat':

      location = await BackgroundGeolocation.getCurrentPosition({
        samples: 2,
        persist: true,
        extras: {
          event: 'heartbeat',
          headless: true,
        },
      });
      console.log('[BackgroundGeolocation HeadlessTask] - getCurrentPosition:', location);
      break;
    case 'authorization':

      break;
  }
};

BackgroundGeolocation.registerHeadlessTask(BackgroundGeolocationHeadlessTask);

Any ideas / advice much appreciated! 🙂

Debug logs

Logs ``` 02-18 20:14:35.633 DEBUG [TSConfig e] ℹ️ Persist config, dirty: [headers] 02-18 20:14:35.633 INFO [HttpService flush] ╔═════════════════════════════════════════════ ║ HTTP Service (count: 0) ╠═════════════════════════════════════════════ 02-18 20:14:35.646 INFO [HttpService flush] ╔═════════════════════════════════════════════ ║ HTTP Service (count: 0) ╠═════════════════════════════════════════════ 02-18 20:14:59.588 DEBUG [TSConfig e] ℹ️ Persist config, dirty: [headers] 02-18 20:14:59.593 INFO [HttpService flush] ╔═════════════════════════════════════════════ ║ HTTP Service (count: 0) ╠═════════════════════════════════════════════ 02-18 20:15:02.436 INFO [LocationAuthorization withBackgroundPermission] 🔵 LocationAuthorization: Requesting Background permission 02-18 20:15:03.188 DEBUG [LifecycleManager onPause] ☯️ onPause 02-18 20:15:04.942 INFO [LocationAuthorization$j onPermissionGranted] ✅ LocationAuthorization: Permission granted 02-18 20:15:04.971 INFO [LocationAuthorization d] 🔵 Should show backgroundPermissionRationale? true 02-18 20:15:04.976 DEBUG [LifecycleManager onResume] ☯️ onResume 02-18 20:15:05.203 DEBUG [TSLocationManagerActivity a] android.permission.ACCESS_BACKGROUND_LOCATION 02-18 20:15:06.496 DEBUG [TSLocationManagerActivity c] eventCount: 0 02-18 20:15:06.592 DEBUG [TSLocationManagerActivity onDestroy] 02-18 20:15:07.285 DEBUG [LifecycleManager onPause] ☯️ onPause 02-18 20:15:07.353 DEBUG [LifecycleManager onStop] ☯️ onStop 02-18 20:15:08.499 DEBUG [LifecycleManager onStart] ☯️ onStart 02-18 20:15:08.549 INFO [LocationAuthorization$j onPermissionGranted] ✅ LocationAuthorization: Permission granted 02-18 20:15:08.566 DEBUG [LifecycleManager onResume] ☯️ onResume 02-18 20:15:08.770 DEBUG [TSLocationManagerActivity a] locationsettings 02-18 20:15:08.773 DEBUG [TSConfig translateDesiredAccuracy] translateDesiredAccuracy (true): -1 02-18 20:15:08.812 DEBUG [TSLocationManagerActivity c] eventCount: 0 02-18 20:15:08.839 DEBUG [TSLocationManagerActivity onDestroy] 02-18 20:15:09.516 DEBUG [LifecycleManager onPause] ☯️ onPause 02-18 20:15:09.859 DEBUG [LifecycleManager onResume] ☯️ onResume 02-18 20:15:14.388 ERROR [BackgroundGeolocation$w0 uncaughtException] ‼️ Uncaught Exception: Error: Hello, Sentry!, js engine: hermes, stack: onPress@1:1732255 _performTransitionSideEffects@1:445567 _receiveSignal@1:445182 onResponderRelease@1:444353 invokeGuardedCallbackImpl@1:348506 invokeGuardedCallback@1:348563 invokeGuardedCallbackAndCatchFirstError@1:348595 executeDispatch@1:348724 executeDispatchesAndReleaseTopLevel@1:352922 forEachAccumulated@1:350213 anonymous@1:353285 batchedUpdatesImpl@1:411502 batchedUpdates@1:352838 _receiveRootNodeIDEvent@1:353123 receiveTouches@1:406380 __callFunction@1:119234 anonymous@1:117676 __guard@1:118616 callFunctionReturnFlushedQueue@1:117634 {"activityRecognitionInterval":10000,"allowIdenticalLocations":false,"authorization":{},"autoSync":true,"autoSyncThreshold":0,"backgroundPermissionRationale":{"title":"Allow access to this device's location in the background?","message":"In order to log your commuting activity automatically, please enable 'Allow all the time permission","positiveAction":"Change to Allow all the time","negativeAction":""},"batchSync":false,"configUrl":"","debug":false,"deferTime":0,"desiredAccuracy":-1,"desiredOdometerAccuracy":100,"disableAutoSyncOnCellular":false,"disableElasticity":false,"disableLocationAuthorizationAlert":false,"disableMotionActivityUpdates":false,"disableProviderChangeRecord":false,"disableStopDetection":false,"distanceFilter":10,"elasticityMultiplier":1,"enableHeadless":true,"enableTimestampMeta":false,"extras":{"org":"mobilityways"},"fastestLocationUpdateInterval":-1,"foregroundService":true,"geofenceInitialTriggerEntry":true,"geofenceModeHighAccuracy":false,"geofenceProximityRadius":1000,"geofenceTemplate":"","headers":{"authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.removed"},"headlessJobService":"com.transistorsoft.rnbackgroundgeolocation.HeadlessTask","heartbeatInterval":-1,"httpRootProperty":"location","httpTimeout":60000,"isMoving":false,"locationAuthorizationRequest":"Always","locationTemplate":"","locationTimeout":60,"locationUpdateInterval":1000,"locationsOrderDirection":"ASC","logLevel":5,"logMaxDays":3,"maxBatchSize":-1,"maxDaysToPersist":1,"maxMonitoredGeofences":97,"maxRecordsToPersist":-1,"method":"POST","minimumActivityRecognitionConfidence":75,"motionTriggerDelay":0,"notification":{"layout":"","title":"Mobilityways POC tracking","text":"Location tracking on","color":"","channelName":"TSLocationManager","channelId":"","smallIcon":"","largeIcon":"","priority":-1,"sticky":false,"strings":{},"actions":[]},"params":{},"persist":true,"persistMode":2,"schedule":[],"scheduleUseAlarmManager":false,"speedJumpFilter":300,"startOnBoot":true,"stationaryRadius":25,"stopAfterElapsedMinutes":0,"stopOnStationary":false,"stopOnTerminate":false,"stopTimeout":5,"triggerActivities":"in_vehicle, on_bicycle, on_foot, running, walking","url":"https:\/\/liftshare-test-proxy.azurewebsites.net\/v2\/liftshare\/location-data","useSignificantChangesOnly":false,"enabled":false,"schedulerEnabled":false,"trackingMode":1,"odometer":0,"isFirstBoot":false,"didLaunchInBackground":false,"didDeviceReboot":false} com.facebook.react.common.JavascriptException: Error: Hello, Sentry!, js engine: hermes, stack: onPress@1:1732255 _performTransitionSideEffects@1:445567 _receiveSignal@1:445182 onResponderRelease@1:444353 invokeGuardedCallbackImpl@1:348506 invokeGuardedCallback@1:348563 invokeGuardedCallbackAndCatchFirstError@1:348595 executeDispatch@1:348724 executeDispatchesAndReleaseTopLevel@1:352922 forEachAccumulated@1:350213 anonymous@1:353285 batchedUpdatesImpl@1:411502 batchedUpdates@1:352838 _receiveRootNodeIDEvent@1:353123 receiveTouches@1:406380 __callFunction@1:119234 anonymous@1:117676 __guard@1:118616 callFunctionReturnFlushedQueue@1:117634 at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:65) at java.lang.reflect.Method.invoke(Native Method) at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:149) at com.facebook.jni.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:234) at java.lang.Thread.run(Thread.java:1012) 02-18 20:15:22.356 INFO [LoggerFacade$a a] ╔═════════════════════════════════════════════ ║ TSLocationManager version: 3.5.3 (432) ╠═════════════════════════════════════════════ ╟─ Google Pixel 6 @ 14 (react) { "activityRecognitionInterval": 10000, "allowIdenticalLocations": false, "authorization": {}, "autoSync": true, "autoSyncThreshold": 0, "backgroundPermissionRationale": { "title": "Allow access to this device's location in the background?", "message": "In order to log your commuting activity automatically, please enable 'Allow all the time permission", "positiveAction": "Change to Allow all the time", "negativeAction": "" }, "batchSync": false, "configUrl": "", "debug": false, "deferTime": 0, "desiredAccuracy": -1, "desiredOdometerAccuracy": 100, "disableAutoSyncOnCellular": false, "disableElasticity": false, "disableLocationAuthorizationAlert": false, "disableMotionActivityUpdates": false, "disableProviderChangeRecord": false, "disableStopDetection": false, "distanceFilter": 10, "elasticityMultiplier": 1, "enableHeadless": true, "enableTimestampMeta": false, "extras": { "org": "mobilityways" }, "fastestLocationUpdateInterval": -1, "foregroundService": true, "geofenceInitialTriggerEntry": true, "geofenceModeHighAccuracy": false, "geofenceProximityRadius": 1000, "geofenceTemplate": "", "headers": { "authorization": "Bearer removed" }, "headlessJobService": "com.transistorsoft.rnbackgroundgeolocation.HeadlessTask", "heartbeatInterval": -1, "httpRootProperty": "location", "httpTimeout": 60000, "isMoving": false, "locationAuthorizationRequest": "Always", "locationTemplate": "", "locationTimeout": 60, "locationUpdateInterval": 1000, "locationsOrderDirection": "ASC", "logLevel": 5, "logMaxDays": 3, "maxBatchSize": -1, "maxDaysToPersist": 1, "maxMonitoredGeofences": 97, "maxRecordsToPersist": -1, "method": "POST", "minimumActivityRecognitionConfidence": 75, "motionTriggerDelay": 0, "notification": { "layout": "", "title": "Mobilityways POC tracking", "text": "Location tracking on", "color": "", "channelName": "TSLocationManager", "channelId": "", "smallIcon": "", "largeIcon": "", "priority": -1, "sticky": false, "strings": {}, "actions": [] }, "params": {}, "persist": true, "persistMode": 2, "schedule": [], "scheduleUseAlarmManager": false, "speedJumpFilter": 300, "startOnBoot": true, "stationaryRadius": 25, "stopAfterElapsedMinutes": 0, "stopOnStationary": false, "stopOnTerminate": false, "stopTimeout": 5, "triggerActivities": "in_vehicle, on_bicycle, on_foot, running, walking", "url": "https:\/\/liftshare-test-proxy.azurewebsites.net\/v2\/liftshare\/location-data", "useSignificantChangesOnly": false, "enabled": false, "schedulerEnabled": false, "trackingMode": 1, "odometer": 0, "isFirstBoot": false, "didLaunchInBackground": false, "didDeviceReboot": false } 02-18 20:15:22.357 INFO [TSConfig print] ╔═════════════════════════════════════════════ ║ DEVICE SENSORS ╠═════════════════════════════════════════════ ╟─ ✅ ACCELEROMETER: {Sensor name="LSM6DSR Accelerometer", vendor="STMicro", version=1, type=1, maxRange=156.9064, resolution=0.0047856453, power=0.001, minDelay=5000} ╟─ ✅ GYROSCOPE: {Sensor name="LSM6DSR Gyroscope", vendor="STMicro", version=1, type=4, maxRange=34.906063, resolution=0.0012217305, power=0.001, minDelay=5000} ╟─ ✅ MAGNETOMETER: {Sensor name="MMC56X3X Magnetometer", vendor="MEMSIC", version=1, type=2, maxRange=3198.1567, resolution=0.0976, power=0.001, minDelay=10000} ╟─ ✅ SIGNIFICANT_MOTION: {Sensor name="Significant Motion (wake-up)", vendor="Google", version=1, type=17, maxRange=1.0, resolution=1.0, power=0.001, minDelay=-1} ╚═════════════════════════════════════════════ 02-18 20:15:22.393 DEBUG [TSSQLiteAppender$c run] ℹ️ Cleared logs older than 72 hours 02-18 20:15:22.461 DEBUG [LifecycleManager onCreate] ☯️ onCreate 02-18 20:15:22.462 DEBUG [LifecycleManager onStart] ☯️ onStart 02-18 20:15:22.462 DEBUG [LifecycleManager onResume] ☯️ onResume 02-18 20:15:22.462 INFO [BackgroundGeolocation ] ✅ Google Play Services: connected (version code:12451000) 02-18 20:15:22.478 INFO [TSProviderManager startMonitoring] 🎾 Start monitoring location-provider changes 02-18 20:15:22.482 DEBUG [SQLiteLocationDAO prune] ℹ️ PRUNE -1 days 02-18 20:15:22.772 DEBUG [TSConfig e] ℹ️ Persist config, dirty: [backgroundPermissionRationale, backgroundPermissionRationale.title, backgroundPermissionRationale.message, backgroundPermissionRationale.positiveAction, desiredAccuracy, enableHeadless, extras, headers, headlessJobService, logLevel, notification, notification.title, notification.text, params, schedule, startOnBoot, stopOnTerminate, url] 02-18 20:15:22.777 INFO [HttpService flush] ╔═════════════════════════════════════════════ ║ HTTP Service (count: 0) ╠═════════════════════════════════════════════ 02-18 20:15:22.778 DEBUG [TSConfig e] ℹ️ Persist config, dirty: [headers] 02-18 20:15:22.780 INFO [HttpService flush] ╔═════════════════════════════════════════════ ║ HTTP Service (count: 0) ╠═════════════════════════════════════════════ 02-18 20:15:22.815 DEBUG [TSConfig e] ℹ️ Persist config, dirty: [headers] 02-18 20:15:23.034 INFO [HttpService flush] ╔═════════════════════════════════════════════ ║ HTTP Service (count: 0) ╠═════════════════════════════════════════════ 02-18 20:15:30.953 DEBUG [LifecycleManager onPause] ☯️ onPause 02-18 20:15:30.960 DEBUG [LifecycleManager onStop] ☯️ onStop 02-18 20:17:45.537 DEBUG [LifecycleManager onStart] ☯️ onStart 02-18 20:17:45.544 DEBUG [LifecycleManager onResume] ☯️ onResume 02-18 20:17:53.898 DEBUG [LifecycleManager onPause] ☯️ onPause 02-18 20:17:53.904 DEBUG [LifecycleManager onStop] ☯️ onStop 02-18 20:18:30.226 INFO [LoggerFacade$a a] ╔═════════════════════════════════════════════ ║ TSLocationManager version: 3.5.3 (432) ╠═════════════════════════════════════════════ ╟─ Google Pixel 6 @ 14 (react) { "activityRecognitionInterval": 10000, "allowIdenticalLocations": false, "authorization": {}, "autoSync": true, "autoSyncThreshold": 0, "backgroundPermissionRationale": { "title": "Allow access to this device's location in the background?", "message": "In order to log your commuting activity automatically, please enable 'Allow all the time permission", "positiveAction": "Change to Allow all the time", "negativeAction": "" }, "batchSync": false, "configUrl": "", "debug": false, "deferTime": 0, "desiredAccuracy": -1, "desiredOdometerAccuracy": 100, "disableAutoSyncOnCellular": false, "disableElasticity": false, "disableLocationAuthorizationAlert": false, "disableMotionActivityUpdates": false, "disableProviderChangeRecord": false, "disableStopDetection": false, "distanceFilter": 10, "elasticityMultiplier": 1, "enableHeadless": true, "enableTimestampMeta": false, "extras": { "org": "mobilityways" }, "fastestLocationUpdateInterval": -1, "foregroundService": true, "geofenceInitialTriggerEntry": true, "geofenceModeHighAccuracy": false, "geofenceProximityRadius": 1000, "geofenceTemplate": "", "headers": { "authorization": "Bearer removed" }, "headlessJobService": "com.transistorsoft.rnbackgroundgeolocation.HeadlessTask", "heartbeatInterval": -1, "httpRootProperty": "location", "httpTimeout": 60000, "isMoving": false, "locationAuthorizationRequest": "Always", "locationTemplate": "", "locationTimeout": 60, "locationUpdateInterval": 1000, "locationsOrderDirection": "ASC", "logLevel": 5, "logMaxDays": 3, "maxBatchSize": -1, "maxDaysToPersist": 1, "maxMonitoredGeofences": 97, "maxRecordsToPersist": -1, "method": "POST", "minimumActivityRecognitionConfidence": 75, "motionTriggerDelay": 0, "notification": { "layout": "", "title": "Mobilityways POC tracking", "text": "Location tracking on", "color": "", "channelName": "TSLocationManager", "channelId": "", "smallIcon": "", "largeIcon": "", "priority": -1, "sticky": false, "strings": {}, "actions": [] }, "params": {}, "persist": true, "persistMode": 2, "schedule": [], "scheduleUseAlarmManager": false, "speedJumpFilter": 300, "startOnBoot": true, "stationaryRadius": 25, "stopAfterElapsedMinutes": 0, "stopOnStationary": false, "stopOnTerminate": false, "stopTimeout": 5, "triggerActivities": "in_vehicle, on_bicycle, on_foot, running, walking", "url": "https:\/\/liftshare-test-proxy.azurewebsites.net\/v2\/liftshare\/location-data", "useSignificantChangesOnly": false, "enabled": false, "schedulerEnabled": false, "trackingMode": 1, "odometer": 0, "isFirstBoot": false, "didLaunchInBackground": false, "didDeviceReboot": false } 02-18 20:18:30.228 INFO [LoggerFacade$a a] ╔═════════════════════════════════════════════ ║ DEVICE SENSORS ╠═════════════════════════════════════════════ ╟─ ✅ ACCELEROMETER: {Sensor name="LSM6DSR Accelerometer", vendor="STMicro", version=1, type=1, maxRange=156.9064, resolution=0.0047856453, power=0.001, minDelay=5000} ╟─ ✅ GYROSCOPE: {Sensor name="LSM6DSR Gyroscope", vendor="STMicro", version=1, type=4, maxRange=34.906063, resolution=0.0012217305, power=0.001, minDelay=5000} ╟─ ✅ MAGNETOMETER: {Sensor name="MMC56X3X Magnetometer", vendor="MEMSIC", version=1, type=2, maxRange=3198.1567, resolution=0.0976, power=0.001, minDelay=10000} ╟─ ✅ SIGNIFICANT_MOTION: {Sensor name="Significant Motion (wake-up)", vendor="Google", version=1, type=17, maxRange=1.0, resolution=1.0, power=0.001, minDelay=-1} ╚═════════════════════════════════════════════ 02-18 20:18:30.229 INFO [LoggerFacade$a a] ╔═════════════════════════════════════════════ ║ BootReceiver: com.mobilityways.app ╠═════════════════════════════════════════════ ╟─ android.intent.action.MY_PACKAGE_REPLACED 02-18 20:18:30.309 DEBUG [LifecycleManager onCreate] ☯️ onCreate 02-18 20:18:30.309 INFO [BackgroundGeolocation ] ✅ Google Play Services: connected (version code:12451000) 02-18 20:18:30.329 DEBUG [TSSQLiteAppender$c run] ℹ️ Cleared logs older than 72 hours 02-18 20:18:30.360 DEBUG [LifecycleManager b] ╔═════════════════════════════════════════════ ║ ☯️ HeadlessMode? true ╠═════════════════════════════════════════════ 02-18 20:18:30.373 INFO [TSProviderManager startMonitoring] 🎾 Start monitoring location-provider changes 02-18 20:18:30.383 DEBUG [TSGeofenceManager d] ℹ️ Persist monitored geofences: [] 02-18 20:18:30.391 DEBUG [SQLiteLocationDAO prune] ℹ️ PRUNE -1 days 02-18 20:18:31.385 DEBUG [LifecycleManager onStart] ☯️ onStart 02-18 20:18:31.387 DEBUG [LifecycleManager onResume] ☯️ onResume 02-18 20:18:31.796 DEBUG [TSConfig e] ℹ️ Persist config, dirty: [backgroundPermissionRationale, backgroundPermissionRationale.title, backgroundPermissionRationale.message, backgroundPermissionRationale.positiveAction, desiredAccuracy, enableHeadless, extras, headers, headlessJobService, logLevel, notification, notification.title, notification.text, params, schedule, startOnBoot, stopOnTerminate, url] 02-18 20:18:31.798 INFO [HttpService flush] ╔═════════════════════════════════════════════ ║ HTTP Service (count: 0) ╠═════════════════════════════════════════════ 02-18 20:18:31.799 DEBUG [TSConfig e] ℹ️ Persist config, dirty: [headers] 02-18 20:18:31.800 INFO [HttpService flush] ╔═════════════════════════════════════════════ ║ HTTP Service (count: 0) ╠═════════════════════════════════════════════ 02-18 20:18:31.820 DEBUG [TSConfig e] ℹ️ Persist config, dirty: [headers] 02-18 20:18:31.825 INFO [HttpService flush] ╔═════════════════════════════════════════════ ║ HTTP Service (count: 0) ╠═════════════════════════════════════════════ 02-18 20:18:44.030 DEBUG [LifecycleManager onPause] ☯️ onPause 02-18 20:18:44.033 DEBUG [LifecycleManager onStop] ☯️ onStop 02-18 20:22:40.017 DEBUG [LifecycleManager onStart] ☯️ onStart 02-18 20:22:40.026 DEBUG [LifecycleManager onResume] ☯️ onResume 02-18 20:23:26.246 DEBUG [TSConfig e] ℹ️ Persist config, dirty: [schedule] 02-18 20:23:26.294 INFO [TSScheduleManager start] ╔═════════════════════════════════════════════ ║ 🎾 Scheduler ON ╠═════════════════════════════════════════════ ╟─ Schedule[10:00-13:00, Days: [2, 3, 4, 5, 6], trackingMode: 1] ╚═════════════════════════════════════════════ 02-18 20:23:26.295 DEBUG [TSScheduleManager a] 📅 Day #1: Searching schedule for alarms... 02-18 20:23:26.296 DEBUG [TSScheduleManager a] 📅 Day #1: Failed to find alarms on this day. Trying tomorrow... 02-18 20:23:26.296 DEBUG [TSScheduleManager a] 📅 Day #2: Searching schedule for alarms... 02-18 20:23:26.299 INFO [TSScheduleManager a] 📅 Scheduled Alarm: ON at 10:00 on Monday 02-18 20:23:26.300 DEBUG [TSScheduleManager a] ℹ️ JobScheduler triggerDelay: 48993700 02-18 20:23:34.671 DEBUG [LifecycleManager onPause] ☯️ onPause 02-18 20:23:34.676 DEBUG [LifecycleManager onStop] ☯️ onStop 02-19 10:01:23.335 DEBUG [LoggerFacade$a a] 02-19 10:01:23.335 INFO [BackgroundGeolocation ] ✅ Google Play Services: connected (version code:12451000) 02-19 10:01:23.335 DEBUG [LifecycleManager onCreate] ☯️ onCreate 02-19 10:01:23.336 INFO [LoggerFacade$a a] ╔═════════════════════════════════════════════ ║ TSLocationManager version: 3.5.3 (432) ╠═════════════════════════════════════════════ ╟─ Google Pixel 6 @ 14 (react) { "activityRecognitionInterval": 10000, "allowIdenticalLocations": false, "authorization": {}, "autoSync": true, "autoSyncThreshold": 0, "backgroundPermissionRationale": { "title": "Allow access to this device's location in the background?", "message": "In order to log your commuting activity automatically, please enable 'Allow all the time permission", "positiveAction": "Change to Allow all the time", "negativeAction": "" }, "batchSync": false, "configUrl": "", "debug": false, "deferTime": 0, "desiredAccuracy": -1, "desiredOdometerAccuracy": 100, "disableAutoSyncOnCellular": false, "disableElasticity": false, "disableLocationAuthorizationAlert": false, "disableMotionActivityUpdates": false, "disableProviderChangeRecord": false, "disableStopDetection": false, "distanceFilter": 10, "elasticityMultiplier": 1, "enableHeadless": true, "enableTimestampMeta": false, "extras": { "org": "mobilityways" }, "fastestLocationUpdateInterval": -1, "foregroundService": true, "geofenceInitialTriggerEntry": true, "geofenceModeHighAccuracy": false, "geofenceProximityRadius": 1000, "geofenceTemplate": "", "headers": { "authorization": "Bearer removed" }, "headlessJobService": "com.transistorsoft.rnbackgroundgeolocation.HeadlessTask", "heartbeatInterval": -1, "httpRootProperty": "location", "httpTimeout": 60000, "isMoving": false, "locationAuthorizationRequest": "Always", "locationTemplate": "", "locationTimeout": 60, "locationUpdateInterval": 1000, "locationsOrderDirection": "ASC", "logLevel": 5, "logMaxDays": 3, "maxBatchSize": -1, "maxDaysToPersist": 1, "maxMonitoredGeofences": 97, "maxRecordsToPersist": -1, "method": "POST", "minimumActivityRecognitionConfidence": 75, "motionTriggerDelay": 0, "notification": { "layout": "", "title": "Mobilityways POC tracking", "text": "Location tracking on", "color": "", "channelName": "TSLocationManager", "channelId": "", "smallIcon": "", "largeIcon": "", "priority": -1, "sticky": false, "strings": {}, "actions": [] }, "params": {}, "persist": true, "persistMode": 2, "schedule": [ "2,3,4,5,6 10:00-13:00" ], "scheduleUseAlarmManager": false, "speedJumpFilter": 300, "startOnBoot": true, "stationaryRadius": 25, "stopAfterElapsedMinutes": 0, "stopOnStationary": false, "stopOnTerminate": false, "stopTimeout": 5, "triggerActivities": "in_vehicle, on_bicycle, on_foot, running, walking", "url": "https:\/\/liftshare-test-proxy.azurewebsites.net\/v2\/liftshare\/location-data", "useSignificantChangesOnly": false, "enabled": false, "schedulerEnabled": true, "trackingMode": 1, "odometer": 0, "isFirstBoot": false, "didLaunchInBackground": false, "didDeviceReboot": false } 02-19 10:01:23.336 INFO [LoggerFacade$a a] ╔═════════════════════════════════════════════ ║ DEVICE SENSORS ╠═════════════════════════════════════════════ ╟─ ✅ ACCELEROMETER: {Sensor name="LSM6DSR Accelerometer", vendor="STMicro", version=1, type=1, maxRange=156.9064, resolution=0.0047856453, power=0.001, minDelay=5000} ╟─ ✅ GYROSCOPE: {Sensor name="LSM6DSR Gyroscope", vendor="STMicro", version=1, type=4, maxRange=34.906063, resolution=0.0012217305, power=0.001, minDelay=5000} ╟─ ✅ MAGNETOMETER: {Sensor name="MMC56X3X Magnetometer", vendor="MEMSIC", version=1, type=2, maxRange=3198.1567, resolution=0.0976, power=0.001, minDelay=10000} ╟─ ✅ SIGNIFICANT_MOTION: {Sensor name="Significant Motion (wake-up)", vendor="Google", version=1, type=17, maxRange=1.0, resolution=1.0, power=0.001, minDelay=-1} ╚═════════════════════════════════════════════ 02-19 10:01:23.336 DEBUG [TSSQLiteAppender$c run] ℹ️ Cleared logs older than 72 hours 02-19 10:01:23.367 INFO [TSProviderManager startMonitoring] 🎾 Start monitoring location-provider changes 02-19 10:01:23.373 INFO [ScheduleEvent a] ╔═════════════════════════════════════════════ ║ 📅 Schedule alarm fired! enabled: true, trackingMode: 1 ╠═════════════════════════════════════════════ 02-19 10:01:23.378 INFO [TSGeofenceManager start] 🎾 Start monitoring geofences 02-19 10:01:23.378 DEBUG [HeadlessTask onHeadlessEvent] 💀 event: enabledchange 02-19 10:01:23.385 DEBUG [SQLiteLocationDAO prune] ℹ️ PRUNE -1 days 02-19 10:01:23.387 DEBUG [HttpService startMonitoringConnectivityChanges] 🎾 Start monitoring connectivity changes 02-19 10:01:23.396 DEBUG [DeviceSettings startMonitoringPowerSaveChanges] 🎾 Start monitoring powersave changes 02-19 10:01:23.398 INFO [ActivityRecognitionService start] 🎾 Start motion-activity updates 02-19 10:01:23.434 INFO [HeartbeatService stop] 🔴 Stop heartbeat 02-19 10:01:23.435 DEBUG [HttpService a] ╔═════════════════════════════════════════════ ║ 📶 Connectivity change: connected? true ╠═════════════════════════════════════════════ 02-19 10:01:23.437 INFO [TrackingService changePace] 🔵 setPace: false → false 02-19 10:01:23.440 DEBUG [TSScheduleManager a] 📅 Day #2: Searching schedule for alarms... 02-19 10:01:23.440 INFO [TSScheduleManager a] 📅 Scheduled Alarm: OFF at 13:00 on Monday 02-19 10:01:23.441 DEBUG [TSScheduleManager a] ℹ️ JobScheduler triggerDelay: 10716559 02-19 10:01:23.445 DEBUG [HttpService startMonitoringConnectivityChanges] 🎾 Start monitoring connectivity changes 02-19 10:01:23.445 DEBUG [DeviceSettings startMonitoringPowerSaveChanges] 🎾 Start monitoring powersave changes 02-19 10:01:23.445 INFO [ActivityRecognitionService start] 🎾 Start motion-activity updates 02-19 10:01:23.446 INFO [HeartbeatService stop] 🔴 Stop heartbeat 02-19 10:01:24.087 DEBUG [LifecycleManager b] ╔═════════════════════════════════════════════ ║ ☯️ HeadlessMode? true ╠═════════════════════════════════════════════ 02-19 10:01:24.092 DEBUG [HeadlessTask onHeadlessEvent] 💀 event: schedule 02-19 10:01:24.098 DEBUG [HeadlessTask onHeadlessEvent] 💀 event: connectivitychange 02-19 10:01:24.098 DEBUG [ScheduleJobService onStopJob] 02-19 10:01:24.465 INFO [HttpService flush] ╔═════════════════════════════════════════════ ║ HTTP Service (count: 0) ╠═════════════════════════════════════════════ 02-19 10:01:24.548 INFO [TSLocationManager a] ╔═════════════════════════════════════════════ ║ motionchange LocationResult: 1 (4583ms old) ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused 53.450879,-2.262667 hAcc=100.0 et=+1d15h2m8s285ms alt=79.5 vAcc=100.0 {Bundle[{battery_level=0.52, is_charging=false, odometer=0.0}]}], time: 1708336879965 02-19 10:01:24.549 DEBUG [TSLocationManager a] Median accuracy: 100.0 02-19 10:01:24.566 DEBUG [HeadlessTask onHeadlessEvent] 💀 event: location 02-19 10:01:24.570 DEBUG [HeadlessTask$2 onHeadlessJsTaskStart] taskId: 1 02-19 10:01:24.574 DEBUG [LocationAuthorization withPermission] ℹ️ LocationAuthorization: Permission granted 02-19 10:01:24.575 INFO [TSLocationManager a] ╔═════════════════════════════════════════════ ║ motionchange LocationResult: 2 (4609ms old) ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused 53.450879,-2.262667 hAcc=100.0 et=+1d15h2m8s285ms alt=79.5 vAcc=100.0], time: 1708336879965 02-19 10:01:24.575 DEBUG [TSLocationManager a] Median accuracy: 100.0 02-19 10:01:24.580 DEBUG [HeadlessTask onHeadlessEvent] 💀 event: location 02-19 10:01:24.581 DEBUG [HeadlessTask$2 onHeadlessJsTaskStart] taskId: 2 02-19 10:01:24.582 DEBUG [LocationAuthorization withPermission] ℹ️ LocationAuthorization: Permission granted 02-19 10:01:24.587 WARN [AbstractService startForegroundService] ℹ️ Background FGS launch denied: Retrying with TSLocationManager::FOREGROUND_SERVICE_GEOFENCE...Intent { act=start cmp=com.mobilityways.app/com.transistorsoft.locationmanager.service.LocationRequestService (has extras) } 02-19 10:01:24.590 WARN [AbstractService startForegroundService] ℹ️ Background FGS launch denied: Retrying with TSLocationManager::FOREGROUND_SERVICE_GEOFENCE...Intent { act=start cmp=com.mobilityways.app/com.transistorsoft.locationmanager.service.LocationRequestService (has extras) } 02-19 10:01:24.657 DEBUG [AbstractService$a onLocation] 📍 Location[fused 53.450879,-2.262667 hAcc=100.0 et=+1d15h2m8s285ms alt=79.5 vAcc=100.0] 02-19 10:01:24.661 DEBUG [AbstractService$a onLocation] 📍 Location[fused 53.450879,-2.262667 hAcc=100.0 et=+1d15h2m8s285ms alt=79.5 vAcc=100.0] 02-19 10:01:24.831 DEBUG [HeadlessTask$2 onHeadlessJsTaskStart] taskId: 3 02-19 10:01:24.832 DEBUG [HeadlessTask$2 onHeadlessJsTaskStart] taskId: 4 02-19 10:01:24.832 DEBUG [HeadlessTask$2 onHeadlessJsTaskStart] taskId: 5 02-19 10:01:24.848 DEBUG [HeadlessTask$2 onHeadlessJsTaskFinish] taskId: 1 02-19 10:01:24.849 DEBUG [HeadlessTask$2 onHeadlessJsTaskFinish] taskId: 2 02-19 10:01:24.849 DEBUG [HeadlessTask$2 onHeadlessJsTaskFinish] taskId: 3 02-19 10:01:24.849 DEBUG [HeadlessTask$2 onHeadlessJsTaskFinish] taskId: 4 02-19 10:01:24.850 DEBUG [HeadlessTask$2 onHeadlessJsTaskFinish] taskId: 5 02-19 14:01:00.058 DEBUG [ScheduleEvent a] 02-19 14:01:00.137 INFO [ScheduleEvent a] ╔═════════════════════════════════════════════ ║ 📅 Schedule alarm fired! enabled: false, trackingMode: 1 ╠═════════════════════════════════════════════ 02-19 14:01:00.140 DEBUG [HttpService a] ╔═════════════════════════════════════════════ ║ 📶 Connectivity change: connected? true ╠═════════════════════════════════════════════ 02-19 14:01:00.149 DEBUG [HeadlessTask onHeadlessEvent] 💀 event: connectivitychange 02-19 14:01:00.202 INFO [TSProviderManager stopMonitoring] 🔴 Stop monitoring location-provider changes 02-19 14:01:00.223 DEBUG [HeadlessTask$2 onHeadlessJsTaskStart] taskId: 6 02-19 14:01:00.249 DEBUG [HeadlessTask onHeadlessEvent] 💀 event: enabledchange 02-19 14:01:00.258 DEBUG [HeadlessTask$2 onHeadlessJsTaskStart] taskId: 7 02-19 14:01:00.312 DEBUG [HeadlessTask$2 onHeadlessJsTaskFinish] taskId: 6 02-19 14:01:00.323 DEBUG [HeadlessTask$2 onHeadlessJsTaskFinish] taskId: 7 02-19 14:01:00.332 DEBUG [TSLocationManager a] ℹ️ Clear last odometer location 02-19 14:01:00.350 DEBUG [TSGeofenceManager c] 🔴 Stop monitoring geofences 02-19 14:01:00.358 INFO [ActivityRecognitionService stop] 🔴 Stop motion-activity updates 02-19 14:01:00.371 INFO [HeartbeatService stop] 🔴 Stop heartbeat 02-19 14:01:00.379 DEBUG [HttpService stopMonitoringConnectivityChanges] 🔴 Stop monitoring connectivity changes 02-19 14:01:00.381 DEBUG [DeviceSettings stopMonitoringPowerSaveChanges] 🔴 Stop monitoring powersave changes 02-19 14:01:00.388 DEBUG [HeadlessTask onHeadlessEvent] 💀 event: schedule 02-19 14:01:00.389 DEBUG [HeadlessTask$2 onHeadlessJsTaskStart] taskId: 8 02-19 14:01:00.395 DEBUG [TSScheduleManager a] 📅 Day #2: Searching schedule for alarms... 02-19 14:01:00.396 DEBUG [TSScheduleManager a] 📅 Day #2: Failed to find alarms on this day. Trying tomorrow... 02-19 14:01:00.396 DEBUG [TSScheduleManager a] 📅 Day #3: Searching schedule for alarms... 02-19 14:01:00.397 INFO [TSScheduleManager a] 📅 Scheduled Alarm: ON at 10:00 on Tuesday 02-19 14:01:00.397 DEBUG [TSScheduleManager a] ℹ️ JobScheduler triggerDelay: 71939603 02-19 14:01:00.398 DEBUG [ScheduleJobService onStopJob] 02-19 14:01:00.418 DEBUG [HeadlessTask$2 onHeadlessJsTaskFinish] taskId: 8 02-19 14:01:01.144 INFO [HttpService flush] ╔═════════════════════════════════════════════ ║ HTTP Service (count: 0) ╠═════════════════════════════════════════════ 02-19 20:15:22.626 INFO [LoggerFacade$a a] ╔═════════════════════════════════════════════ ║ TSLocationManager version: 3.5.3 (432) ╠═════════════════════════════════════════════ ╟─ Google Pixel 6 @ 14 (react) { "activityRecognitionInterval": 10000, "allowIdenticalLocations": false, "authorization": {}, "autoSync": true, "autoSyncThreshold": 0, "backgroundPermissionRationale": { "title": "Allow access to this device's location in the background?", "message": "In order to log your commuting activity automatically, please enable 'Allow all the time permission", "positiveAction": "Change to Allow all the time", "negativeAction": "" }, "batchSync": false, "configUrl": "", "debug": false, "deferTime": 0, "desiredAccuracy": -1, "desiredOdometerAccuracy": 100, "disableAutoSyncOnCellular": false, "disableElasticity": false, "disableLocationAuthorizationAlert": false, "disableMotionActivityUpdates": false, "disableProviderChangeRecord": false, "disableStopDetection": false, "distanceFilter": 10, "elasticityMultiplier": 1, "enableHeadless": true, "enableTimestampMeta": false, "extras": { "org": "mobilityways" }, "fastestLocationUpdateInterval": -1, "foregroundService": true, "geofenceInitialTriggerEntry": true, "geofenceModeHighAccuracy": false, "geofenceProximityRadius": 1000, "geofenceTemplate": "", "headers": { "authorization": "Bearer removed" }, "headlessJobService": "com.transistorsoft.rnbackgroundgeolocation.HeadlessTask", "heartbeatInterval": -1, "httpRootProperty": "location", "httpTimeout": 60000, "isMoving": false, "locationAuthorizationRequest": "Always", "locationTemplate": "", "locationTimeout": 60, "locationUpdateInterval": 1000, "locationsOrderDirection": "ASC", "logLevel": 5, "logMaxDays": 3, "maxBatchSize": -1, "maxDaysToPersist": 1, "maxMonitoredGeofences": 97, "maxRecordsToPersist": -1, "method": "POST", "minimumActivityRecognitionConfidence": 75, "motionTriggerDelay": 0, "notification": { "layout": "", "title": "Mobilityways POC tracking", "text": "Location tracking on", "color": "", "channelName": "TSLocationManager", "channelId": "", "smallIcon": "", "largeIcon": "", "priority": -1, "sticky": false, "strings": {}, "actions": [] }, "params": {}, "persist": true, "persistMode": 2, "schedule": [ "2,3,4,5,6 10:00-13:00" ], "scheduleUseAlarmManager": false, "speedJumpFilter": 300, "startOnBoot": true, "stationaryRadius": 25, "stopAfterElapsedMinutes": 0, "stopOnStationary": false, "stopOnTerminate": false, "stopTimeout": 5, "triggerActivities": "in_vehicle, on_bicycle, on_foot, running, walking", "url": "https:\/\/liftshare-test-proxy.azurewebsites.net\/v2\/liftshare\/location-data", "useSignificantChangesOnly": false, "enabled": false, "schedulerEnabled": true, "trackingMode": 1, "odometer": 0, "isFirstBoot": false, "didLaunchInBackground": false, "didDeviceReboot": false } 02-19 20:15:22.627 INFO [LoggerFacade$a a] ╔═════════════════════════════════════════════ ║ DEVICE SENSORS ╠═════════════════════════════════════════════ ╟─ ✅ ACCELEROMETER: {Sensor name="LSM6DSR Accelerometer", vendor="STMicro", version=1, type=1, maxRange=156.9064, resolution=0.0047856453, power=0.001, minDelay=5000} ╟─ ✅ GYROSCOPE: {Sensor name="LSM6DSR Gyroscope", vendor="STMicro", version=1, type=4, maxRange=34.906063, resolution=0.0012217305, power=0.001, minDelay=5000} ╟─ ✅ MAGNETOMETER: {Sensor name="MMC56X3X Magnetometer", vendor="MEMSIC", version=1, type=2, maxRange=3198.1567, resolution=0.0976, power=0.001, minDelay=10000} ╟─ ✅ SIGNIFICANT_MOTION: {Sensor name="Significant Motion (wake-up)", vendor="Google", version=1, type=17, maxRange=1.0, resolution=1.0, power=0.001, minDelay=-1} ╚═════════════════════════════════════════════ 02-19 20:15:22.628 DEBUG [TSSQLiteAppender$c run] ℹ️ Cleared logs older than 72 hours 02-19 20:15:22.695 DEBUG [LifecycleManager onCreate] ☯️ onCreate 02-19 20:15:22.695 DEBUG [LifecycleManager onStart] ☯️ onStart 02-19 20:15:22.695 DEBUG [LifecycleManager onResume] ☯️ onResume 02-19 20:15:22.695 INFO [BackgroundGeolocation ] ✅ Google Play Services: connected (version code:12451000) 02-19 20:15:22.702 INFO [TSProviderManager startMonitoring] 🎾 Start monitoring location-provider changes 02-19 20:15:22.705 DEBUG [SQLiteLocationDAO prune] ℹ️ PRUNE -1 days 02-19 20:15:22.903 WARN [TSScheduleManager a] ⚠️ Received an empty schedule 02-19 20:15:22.903 INFO [TSScheduleManager stop] 🔴 Scheduler OFF 02-19 20:15:22.904 DEBUG [TSConfig e] ℹ️ Persist config, dirty: [headers] 02-19 20:15:22.905 INFO [HttpService flush] ╔═════════════════════════════════════════════ ║ HTTP Service (count: 0) ╠═════════════════════════════════════════════ 02-19 20:15:22.916 INFO [HttpService flush] ╔═════════════════════════════════════════════ ║ HTTP Service (count: 0) ╠═════════════════════════════════════════════ 02-19 20:15:22.953 DEBUG [TSConfig e] ℹ️ Persist config, dirty: [headers] 02-19 20:15:22.963 INFO [HttpService flush] ╔═════════════════════════════════════════════ ║ HTTP Service (count: 0) ╠═════════════════════════════════════════════ ```
christocracy commented 6 months ago

ℹ️ Background FGS launch denied: Retrying with TSLocationManager::FOREGROUND_SERVICE_GEOFENCE...Intent { act=start cmp=com.mobilityways.app/com.transistorsoft.locationmanager.service.LocationRequestService (has extras) }

Android 14 has introduced strict new rules about how/when foreground-services can be launched in the background.

I don't think the plugin's schedule is going to work very well without enabling "AlarmManager Exact Alarms"

The plugin attempts to "hack" around these new restrictions by creating a fake geofence-event around the current position but it is unreliable (Retrying with TSLocationManager::FOREGROUND_SERVICE_GEOFENCE). Android 14 foreground launch restrictions allow foreground-services to launch from a geofence event).

christocracy commented 6 months ago

Note that adding USE_EXACT_ALARM permission to your AndroidManifest now requires you to describe to Play Store why you need this permission with a video.

christocracy commented 6 months ago

Also, when you see this:

ℹ️ Background FGS launch denied: Retrying with TSLocationManager::FOREGROUND_SERVICE_GEOFENCE

It's expected to be followed by this:

I/TSLocationManager(31557):   ℹ️  👍 Foreground-service launched with TSLocationManager::FOREGROUND_SERVICE_GEOFENCE
vonkanehoffen commented 6 months ago

Ah thanks @christocracy , that makes sense! @rb1n , looks like we need to make an Expo config plugin to update the AndroidManifest as above - can't edit it directly with our current builds setup

github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 3 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.