Closed vonkanehoffen closed 3 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).
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.
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
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
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
Your Environment
react-native -v
): 0.73.4 (Expo 50.0.6)Plugin config
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
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 at02-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:
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