react-native-background-geolocation
react-native-background-geolocation copied to clipboard
Can not continue to auto-monitor the geofence event without opening the app after restart the android phone(sometimes)
Your Environment
- Plugin version: 4.4.6
- Platform: Android
- OS version: Android 12
- Device manufacturer / model: Pixel4
- React Native version (
react-native -v): 0.63.3" - Plugin config
BackgroundGeolocation.ready({
debug: true,
geofenceModeHighAccuracy: true,
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
distanceFilter: 10,
fastestLocationUpdateInterval: 1000,
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
disableLocationAuthorizationAlert: true,
disableMotionActivityUpdates: true, // disable the motion activity monitor feature
stopOnTerminate: false, // Allow the background-service to continue tracking when app terminated.
startOnBoot: true, // Auto start tracking when device is powered-up.
enableHeadless: true,
});
Expected Behavior
After restarting the phone, the plugin should continue to monitor the geofence event without opening the app
Actual Behavior
Sometimes the plugin will not auto-start to continue to monitor the geofence events after restarting the phone without opening the app
Steps to Reproduce
- add a geofence and stay in the geofence
- restart the phone
- there's no location service or geofence service starting to continue to monitor the geofence.
Context
Restart the phone and the plugin should continue to track the geofence events without opening the app
Debug logs
Logs
05-10 15:55:21.633 9171 9967 I TSLocationManager: [c.t.l.logger.LoggerFacade$a a]
05-10 15:55:21.633 9171 9967 I TSLocationManager: ╔═════════════════════════════════════════════
05-10 15:55:21.633 9171 9967 I TSLocationManager: ║ TSLocationManager version: 3.1.37 (393)
05-10 15:55:21.633 9171 9967 I TSLocationManager: ╠═════════════════════════════════════════════
05-10 15:55:21.633 9171 9967 I TSLocationManager: ╟─ Google Pixel 4 @ 12 (react-native)
05-10 15:55:21.633 9171 9967 I TSLocationManager: {
05-10 15:55:21.633 9171 9967 I TSLocationManager: "activityRecognitionInterval": 10000,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "allowIdenticalLocations": false,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "authorization": {},
05-10 15:55:21.633 9171 9967 I TSLocationManager: "autoSync": true,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "autoSyncThreshold": 0,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "backgroundPermissionRationale": {
05-10 15:55:21.633 9171 9967 I TSLocationManager: "title": "Allow WIL to access your location even when the app is not in use? ",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "message": "Allow WIL to access your location so eligible rewards and offers can be shown to you.",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "positiveAction": "Always allow",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "negativeAction": "Keep only while using"
05-10 15:55:21.633 9171 9967 I TSLocationManager: },
05-10 15:55:21.633 9171 9967 I TSLocationManager: "batchSync": false,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "configUrl": "",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "debug": true,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "deferTime": 0,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "desiredAccuracy": -1,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "desiredOdometerAccuracy": 100,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "disableAutoSyncOnCellular": false,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "disableElasticity": false,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "disableLocationAuthorizationAlert": true,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "disableMotionActivityUpdates": true,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "disableStopDetection": false,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "distanceFilter": 10,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "elasticityMultiplier": 1,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "enableHeadless": true,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "enableTimestampMeta": false,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "extras": {},
05-10 15:55:21.633 9171 9967 I TSLocationManager: "fastestLocationUpdateInterval": 1000,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "foregroundService": true,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "geofenceInitialTriggerEntry": true,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "geofenceModeHighAccuracy": true,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "geofenceProximityRadius": 1000,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "geofenceTemplate": "",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "headers": {},
05-10 15:55:21.633 9171 9967 I TSLocationManager: "headlessJobService": "com.transistorsoft.rnbackgroundgeolocation.HeadlessTask",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "heartbeatInterval": -1,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "httpRootProperty": "location",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "httpTimeout": 60000,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "isMoving": false,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "locationAuthorizationRequest": "Always",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "locationTemplate": "",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "locationTimeout": 60,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "locationUpdateInterval": 1000,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "locationsOrderDirection": "ASC",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "logLevel": 5,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "logMaxDays": 3,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "maxBatchSize": -1,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "maxDaysToPersist": 1,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "maxRecordsToPersist": -1,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "method": "POST",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "minimumActivityRecognitionConfidence": 75,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "motionTriggerDelay": 0,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "notification": {
05-10 15:55:21.633 9171 9967 I TSLocationManager: "layout": "",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "title": "WIL",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "text": "已啟動定位服務。",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "color": "",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "channelName": "TSLocationManager",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "smallIcon": "",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "largeIcon": "",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "priority": 0,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "sticky": false,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "strings": {},
05-10 15:55:21.633 9171 9967 I TSLocationManager: "actions": []
05-10 15:55:21.633 9171 9967 I TSLocationManager: },
05-10 15:55:21.633 9171 9967 I TSLocationManager: "params": {},
05-10 15:55:21.633 9171 9967 I TSLocationManager: "persist": true,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "persistMode": 2,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "schedule": [],
05-10 15:55:21.633 9171 9967 I TSLocationManager: "scheduleUseAlarmManager": false,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "speedJumpFilter": 300,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "startOnBoot": true,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "stationaryRadius": 25,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "stopAfterElapsedMinutes": 0,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "stopOnStationary": false,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "stopOnTerminate": false,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "stopTimeout": 5,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "triggerActivities": "in_vehicle, on_bicycle, on_foot, running, walking",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "url": "",
05-10 15:55:21.633 9171 9967 I TSLocationManager: "useSignificantChangesOnly": false,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "enabled": true,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "schedulerEnabled": false,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "trackingMode": 1,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "odometer": 0,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "isFirstBoot": false,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "didLaunchInBackground": false,
05-10 15:55:21.633 9171 9967 I TSLocationManager: "didDeviceReboot": false
05-10 15:55:21.633 9171 9967 I TSLocationManager: }
05-10 15:55:21.634 9171 9967 I TSLocationManager: [c.t.l.logger.LoggerFacade$a a]
05-10 15:55:21.634 9171 9967 I TSLocationManager: ╔═════════════════════════════════════════════
05-10 15:55:21.634 9171 9967 I TSLocationManager: ║ DEVICE SENSORS
05-10 15:55:21.634 9171 9967 I TSLocationManager: ╠═════════════════════════════════════════════
05-10 15:55:21.634 9171 9967 I TSLocationManager: ╟─ ✅ ACCELEROMETER: {Sensor name="LSM6DSR Accelerometer", vendor="STMicro", version=142856, type=1, maxRange=156.9064, resolution=0.0047856453, power=0.17, minDelay=2404}
05-10 15:55:21.634 9171 9967 I TSLocationManager: ╟─ ✅ GYROSCOPE: {Sensor name="LSM6DSR Gyroscope", vendor="STMicro", version=142856, type=4, maxRange=34.905033, resolution=0.0012216945, power=0.55, minDelay=2404}
05-10 15:55:21.634 9171 9967 I TSLocationManager: ╟─ ✅ MAGNETOMETER: {Sensor name="LIS2MDL Magnetometer", vendor="STMicro", version=262, type=2, maxRange=4915.2, resolution=0.01, power=0.2, minDelay=10000}
05-10 15:55:21.634 9171 9967 I TSLocationManager: ╟─ ✅ SIGNIFICANT_MOTION: {Sensor name="Significant Motion", vendor="Google", version=1, type=17, maxRange=1.0, resolution=1.0, power=0.25, minDelay=-1}
05-10 15:55:21.634 9171 9967 I TSLocationManager: ╚═════════════════════════════════════════════
05-10 15:55:21.641 9171 9967 I TSLocationManager: [c.t.l.logger.LoggerFacade$a a]
05-10 15:55:21.641 9171 9967 I TSLocationManager: ╔═════════════════════════════════════════════
05-10 15:55:21.641 9171 9967 I TSLocationManager: ║ BootReceiver: com.wilson.wilcustomer
05-10 15:55:21.641 9171 9967 I TSLocationManager: ╠═════════════════════════════════════════════
05-10 15:55:21.641 9171 9967 I TSLocationManager: ╟─ android.intent.action.BOOT_COMPLETED
05-10 15:55:21.641 9171 9967 I TSLocationManager: [c.t.l.logger.LoggerFacade$a a]
05-10 15:55:21.641 9171 9967 I TSLocationManager: ✅ Google Play Services: connected (version code:12451000)
05-10 15:55:21.642 9171 9967 D TSLocationManager: [c.t.l.logger.LoggerFacade$a a]
05-10 15:55:21.642 9171 9967 D TSLocationManager: ℹ️ Load last odometer location: Location[TSLocationManager 22.320607,114.171686 hAcc=19.109 et=0 {Bundle[{odometer=0.0}]}]
05-10 15:55:21.642 9171 9967 D TSLocationManager: [c.t.l.logger.LoggerFacade$a a]
05-10 15:55:21.642 9171 9967 D TSLocationManager: 🎾 Start monitoring connectivity changes
05-10 15:55:21.643 9171 9974 D TSLocationManager: [c.t.l.http.HttpService a]
05-10 15:55:21.643 9171 9974 D TSLocationManager: ╔═════════════════════════════════════════════
05-10 15:55:21.643 9171 9974 D TSLocationManager: ║ 📶 Connectivity change: connected? true
05-10 15:55:21.643 9171 9974 D TSLocationManager: ╠═════════════════════════════════════════════
05-10 15:55:21.648 9171 9171 D TSLocationManager: [c.t.l.a.BackgroundGeolocation isMainActivityActive] NO
05-10 15:55:21.652 9171 9949 I TSLocationManager: [c.t.l.a.BackgroundGeolocation d]
05-10 15:55:21.652 9171 9949 I TSLocationManager: 🎾 Start monitoring location-provider changes
05-10 15:55:21.657 9171 9949 D TSLocationManager: [c.t.l.a.BackgroundGeolocation isMainActivityActive] NO
05-10 15:55:21.663 9171 9171 D TSLocationManager: [c.t.r.HeadlessTask onHeadlessEvent] 💀 event: connectivitychange
05-10 15:55:21.685 9171 9976 D TSLocationManager: [c.t.l.data.sqlite.b prune]
05-10 15:55:21.685 9171 9976 D TSLocationManager: ℹ️ PRUNE -1 days
05-10 15:55:21.693 9171 9949 D TSLocationManager: [c.t.l.g.TSGeofenceManager c] ℹ️ Persist monitored geofences: []
05-10 15:55:21.698 9171 9976 D TSLocationManager: [c.t.l.a.BackgroundGeolocation isMainActivityActive] NO
05-10 15:55:21.703 9171 9949 D TSLocationManager: [c.t.l.a.BackgroundGeolocation isMainActivityActive] NO
05-10 15:55:21.724 9171 9976 W TSLocationManager: [c.t.l.s.ActivityRecognitionService b]
05-10 15:55:21.724 9171 9976 W TSLocationManager: ⚠️ Cannot start motion-activity updates: permission is denied
05-10 15:55:21.724 9171 9171 D TSLocationManager: [c.t.l.a.BackgroundGeolocation isMainActivityActive] NO
05-10 15:55:21.725 9171 9171 D TSLocationManager: [c.t.r.HeadlessTask onHeadlessEvent] 💀 event: providerchange
05-10 15:55:21.735 9171 9223 D TSLocationManager: [c.t.l.a.BackgroundGeolocation isMainActivityActive] NO
05-10 15:55:21.744 9171 9949 W TSLocationManager: [c.t.l.s.ActivityRecognitionService b]
05-10 15:55:21.744 9171 9949 W TSLocationManager: ⚠️ Cannot start motion-activity updates: permission is denied
05-10 15:55:21.762 9171 9949 D TSLocationManager: [c.t.l.http.HttpService startMonitoringConnectivityChanges]
05-10 15:55:21.762 9171 9949 D TSLocationManager: 🎾 Start monitoring connectivity changes
05-10 15:55:21.768 9171 9949 D TSLocationManager: [c.t.locationmanager.device.a c]
05-10 15:55:21.768 9171 9949 D TSLocationManager: 🎾 Start monitoring powersave changes
05-10 15:55:21.804 9171 9949 D TSLocationManager: [c.t.locationmanager.util.c h]
05-10 15:55:21.804 9171 9949 D TSLocationManager: ℹ️ LocationAuthorization: Permission granted
05-10 15:55:21.817 9171 9949 I TSLocationManager: [c.t.l.service.HeartbeatService c]
05-10 15:55:21.817 9171 9949 I TSLocationManager: 🔴 Stop heartbeat
05-10 15:55:21.838 9171 9949 D TSLocationManager: [c.t.l.a.BackgroundGeolocation isMainActivityActive] NO
05-10 15:55:21.844 9171 9171 D TSLocationManager: [c.t.r.HeadlessTask onHeadlessEvent] 💀 event: boot
05-10 15:55:22.575 9171 9171 D TSLocationManager: [c.t.r.HeadlessTask$2 onHeadlessJsTaskStart] taskId: 1
05-10 15:55:22.580 9171 9171 D TSLocationManager: [c.t.r.HeadlessTask$2 onHeadlessJsTaskStart] taskId: 2
05-10 15:55:22.582 9171 9171 D TSLocationManager: [c.t.r.HeadlessTask$2 onHeadlessJsTaskStart] taskId: 3
05-10 15:55:28.556 9171 9171 D TSLocationManager: [c.t.r.HeadlessTask$2 onHeadlessJsTaskFinish] taskId: 1
05-10 15:55:28.557 9171 9171 D TSLocationManager: [c.t.r.HeadlessTask$2 onHeadlessJsTaskFinish] taskId: 2
05-10 15:55:28.557 9171 9171 D TSLocationManager: [c.t.r.HeadlessTask$2 onHeadlessJsTaskFinish] taskId: 3
05-10 15:56:21.881 9171 9171 W TSLocationManager: [c.t.l.l.SingleLocationRequest finish]
05-10 15:56:21.881 9171 9171 W TSLocationManager: ⚠️ timeout: 1
05-10 15:56:21.882 9171 9171 W TSLocationManager: [c.t.l.l.TSLocationManager onLocationTimeout]
05-10 15:56:21.882 9171 9171 W TSLocationManager: ⚠️ TSLocationManager received location timeout
05-10 15:56:21.884 9171 9171 W TSLocationManager: [c.t.l.a.BackgroundGeolocation _onLocationError]
05-10 15:56:21.884 9171 9171 W TSLocationManager: ⚠️ Location error: 408
05-10 15:56:21.997 9171 9171 W TSLocationManager: [c.t.l.s.ActivityRecognitionService b]
05-10 15:56:21.997 9171 9171 W TSLocationManager: ⚠️ Cannot start motion-activity updates: permission is denied
05-10 15:56:22.045 9171 9171 D TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎ finish LocationRequestService [eventCount: 0, sticky: false]
05-10 15:56:22.052 9171 9171 D TSLocationManager: [c.t.l.service.AbstractService onDestroy]
05-10 15:56:22.052 9171 9171 D TSLocationManager: 🔴 LocationRequestService destroyed
I'm sure I added geofences into the sdk and I do not know why the log said:
[c.t.l.g.TSGeofenceManager c] ℹ️ Persist monitored geofences: []
How many geofences are you monitoring?
38
The plugin attempted to receive a location at boot and the location api failed to provide one (timeout).
go move around with the device while in that state.
So the plugin will retry to request the location only when the device is moving?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.