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.66k stars 426 forks source link

IOS kill mode: service stop after starting it in still state #2140

Closed Rutvik-tbz closed 4 weeks ago

Rutvik-tbz commented 2 months ago

I want to get a location in kill mode (iOS) My application is already in a kill state, I activate location services (BackgroundGeolocation.start()) using silent notifications. The location service activates successfully and provides 2-3 locations, but then it stops giving updates after that, my mobile is in still mode (on my desk) how can I start it in still mode for some time

If I walk, then it starts successfully.

Your Environment

Steps to Reproduce

  1. First, kill your iOS application.
  2. Send a silent push notification
  3. Start the location service upon receiving the notification.

My .emailLog


2024-09-09 17:53:16.775 πŸ”΅-[LocationManager locationManager:didUpdateLocations:] bgTime remaining: 20

2024-09-09 17:53:19.813 
╔═══════════════════════════════════════════════════════════
β•‘ -[TSLocationManager start] 
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

2024-09-09 17:53:19.813 ℹ️-[TSLocationManager doStart:] trackingMode: 1

2024-09-09 17:53:19.813 ℹ️-[TSConfig persist] 

2024-09-09 17:53:19.819 🎾-[TSGeofenceManager start] 

2024-09-09 17:53:19.820 🎾-[SOMotionDetector startDetection] 

2024-09-09 17:53:19.822 πŸ”΅-[TSLocationManager setPace:] 0

2024-09-09 17:53:19.833 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON

2024-09-09 17:53:19.867 ℹ️+[LocationAuthorization run:onCancel:] status: 3

2024-09-09 17:53:19.906 βœ…-[SOMotionDetector startDetection]_block_invoke Enabled M7 MotionActivity updates

2024-09-09 17:53:19.908 🎾-[TSLocationManager startMonitoringBackgroundFetch] BackgroundFetch: ON

2024-09-09 17:53:19.912 
πŸ“<+23.01923319,+72.51924045> +/- 35.00m (speed -1.00 mps / course -1.00) @ 09/09/24, 17:53:18 India Standard Time

2024-09-09 17:53:19.912 
╔═══════════════════════════════════════════════════════════
β•‘ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 0 | df: -1.0m | age: 1156 ms
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

2024-09-09 17:53:19.912 βœ…-[TSLocationManager locationManager:didUpdateLocations:] Acquired motionchange position: <+23.01923319,+72.51924045> +/- 35.00m (speed -1.00 mps / course -1.00) @ 09/09/24, 17:53:18 India Standard Time

2024-09-09 17:53:19.919 πŸ”΅-[TSLocationManager startMonitoringStationaryRegion:radius:] Radius: 200

2024-09-09 17:53:19.922 πŸ”΅-[TSLocationManager beginHeartbeat] 60

2024-09-09 17:53:19.922 πŸ”΄-[TSLocationManager stopUpdatingLocation] 

2024-09-09 17:53:19.922 πŸ”΅-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 35.0

2024-09-09 17:53:19.922 ℹ️-[PolygonGeofencingService setLocation:] Already updating location <IGNORED>

2024-09-09 17:53:19.923 🎾-[TSLocationManager startMonitoringSignificantLocationChanges] 

2024-09-09 17:53:19.923 βœ…-[LocationDAO unlock]_block_invoke UNLOCKED ALL RECORDS

2024-09-09 17:53:19.972 
╔═══════════════════════════════════════════════════════════
β•‘ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | still/100 | isMoving: 0
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

2024-09-09 17:53:19.974 βœ…-[TSLocationManager persistLocation:]_block_invoke INSERT: E610EB2F-0002-4E83-A281-1BD79A8F5B14

2024-09-09 17:53:19.993 ℹ️-[TSLocationManager startMonitoringBackgroundFetch]_block_invoke Configured BackgroundFetch

2024-09-09 17:53:19.998 βœ…-[BackgroundTaskManager createBackgroundTask] 7

2024-09-09 17:53:19.999 ⚠️-[TSLocationManager start] Already started (ignored)

2024-09-09 17:53:23.100 πŸ”΅-[BackgroundTaskManager onPreventSuspendTimer:] Prevent-suspend timer fired! (bg time remaining: 13.938937)

2024-09-09 17:53:23.127 ℹ️+[LocationAuthorization run:onCancel:] status: 3

2024-09-09 17:53:26.134 πŸ”΅-[BackgroundTaskManager onPreventSuspendTimer:] Prevent-suspend timer fired! (bg time remaining: 10.904675)

2024-09-09 17:53:26.172 ℹ️+[LocationAuthorization run:onCancel:] status: 3

2024-09-09 17:53:29.179 πŸ”΅-[BackgroundTaskManager onPreventSuspendTimer:] Prevent-suspend timer fired! (bg time remaining: 7.859773)

2024-09-09 17:53:29.219 ℹ️+[LocationAuthorization run:onCancel:] status: 3

2024-09-09 17:53:32.225 πŸ”΅-[BackgroundTaskManager onPreventSuspendTimer:] Prevent-suspend timer fired! (bg time remaining: 4.813578)

2024-09-09 17:53:32.264 ℹ️+[LocationAuthorization run:onCancel:] status: 3

2024-09-09 17:53:33.449 ⚠️-[BackgroundTaskManager createBackgroundTask]_block_invoke FORCE KILL BACKGROUND TASK: 7, remaining time: 3.590480

2024-09-09 17:53:33.452 βœ…-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 7 OF (
    7
)

2024-09-09 17:55:07.962 πŸ”΅-[TSLocationManager onHeartbeat] Heartbeat

2024-09-09 17:55:07.965 πŸ”΅-[TSLocationManager onResume:] enabled? 1

2024-09-09 17:55:07.965 ℹ️-[TSDBLogger db_save] Log committed

2024-09-09 17:55:07.967 ℹ️-[LocationDAO purge:] 1

2024-09-09 17:55:07.968 ℹ️-[TSDBLogger db_save] Log committed

2024-09-09 17:55:07.977 
╔═══════════════════════════════════════════════════════════
β•‘ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | still/100 | isMoving: 0
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

2024-09-09 17:55:08.035 πŸ”΅-[TSLocationManager getCurrentPosition:] 

2024-09-09 17:55:08.035 🎾-[LocationManager startUpdatingLocation] ON

2024-09-09 17:55:08.035 πŸ”΅-[TSLocationManager getCurrentPosition:] 

2024-09-09 17:55:08.041 
πŸ“<+23.01929688,+72.51925753> +/- 35.00m (speed -1.00 mps / course -1.00) @ 09/09/24, 17:54:13 India Standard Time

2024-09-09 17:55:08.041 πŸ”΄-[LocationManager stopUpdatingLocation] OFF

2024-09-09 17:55:08.041 
╔═══════════════════════════════════════════════════════════
β•‘ -[LocationManager locationManager:didUpdateLocations:] Sample 1 of 1 (54687 ms old)
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

2024-09-09 17:55:08.042 ℹ️-[PolygonGeofencingService setLocation:] Already updating location <IGNORED>

2024-09-09 17:55:08.042 πŸ”΅-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 35.0

2024-09-09 17:55:08.042 ℹ️-[PolygonGeofencingService setLocation:] Already updating location <IGNORED>

2024-09-09 17:55:08.043 βœ…-[TSLocationManager persistLocation:]_block_invoke INSERT: D0072D1F-7539-4224-953E-C619FFAE7DA1

2024-09-09 17:55:08.044 βœ…-[TSLocationManager persistLocation:]_block_invoke INSERT: EDBC95D9-3571-4911-9489-7504E3EF6092

2024-09-09 17:55:08.049 ℹ️+[LocationAuthorization run:onCancel:] status: 3

2024-09-09 17:55:09.696 
╔═══════════════════════════════════════════════════════════
β•‘ -[TSLocationManager stop] 
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

2024-09-09 17:55:09.696 ℹ️-[TSConfig persist] 

2024-09-09 17:55:09.699 ⚠️-[BackgroundTaskManager stopBackgroundTask:]_block_invoke Failed to find backgroundTask: 7.  Ignoring.

2024-09-09 17:55:09.699 ℹ️-[TSLocationManager clearLastOdometerLocation] 

2024-09-09 17:55:09.699 πŸ”΄-[TSGeofenceManager stop] 

2024-09-09 17:55:09.699 πŸ”΄-[TSGeofenceManager stopMonitoringSignificantLocationChanges] 

2024-09-09 17:55:09.699 πŸ”΄-[TSGeofenceManager stopUpdatingLocation] 

2024-09-09 17:55:09.699 πŸ”΄-[TSGeofenceManager stopMonitoringGeofences] 

2024-09-09 17:55:09.703 πŸ”΄-[PolygonGeofencingService stop] 

2024-09-09 17:55:09.703 ℹ️-[PolygonGeofencingService persistMonitoredPolygons] {
}

2024-09-09 17:55:09.703 πŸ”΄-[SOMotionDetector stopDetection] OFF

2024-09-09 17:55:09.703 πŸ”΄-[TSLocationManager stopUpdatingLocation] 

2024-09-09 17:55:09.703 πŸ”΄-[TSLocationManager stopHeartbeat] 

2024-09-09 17:55:09.703 πŸ”΄-[TSLocationManager stop] Stop monitoring stationary region

2024-09-09 17:55:09.703 πŸ”΄-[TSLocationManager stopMonitoringBackgroundFetch] BackgroundFetch: OFF

2024-09-09 17:55:09.704 πŸ”΄-[TSLocationManager stopMonitoringSignificantLocationChanges] 

2024-09-09 17:55:09.709 πŸ”΄-[TSGeofenceManager stopUpdatingLocation] 

christocracy commented 2 months ago

All those πŸ”΄ messages at the end show you are calling .stop().

Rutvik-tbz commented 2 months ago

@christocracy After starting the service, I do not stop it with (BackgroundGeolocation.start()) is there any configuration change (BackgroundGeolocation.ready()) ??

christocracy commented 2 months ago

is there any configuration change (BackgroundGeolocation.ready()) ??

No.

It’s right there: you’re telling the plug-in to .stop(). Check your code. Either that or the Config you’re actually using is not the same as that posted to this issue.

2024-09-09 17:55:09.696 
╔═══════════════════════════════════════════════════════════
β•‘ -[TSLocationManager stop] 
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
Rutvik-tbz commented 2 months ago

@christocracy, we have the same configuration that we shared. In our application, I removed the code for stopping the location service and then took logs.

after starting service I am not stopping it. but still, the library stop giving updated locations, in the log we can see that


2024-09-10 16:11:48.447 ⚠️-[BackgroundTaskManager createBackgroundTask]_block_invoke FORCE KILL BACKGROUND TASK: 7, remaining time: 4.000219

2024-09-10 16:11:48.447 βœ…-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 7 OF (
    7
)

After this line, the library stops providing updates. After I manually open the application, it starts.

See full logs


╔═══════════════════════════════════════════════════════════
β•‘ -[TSLocationManager start] 
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

2024-09-10 16:11:36.305 ℹ️-[TSLocationManager doStart:] trackingMode: 1

2024-09-10 16:11:36.305 ℹ️-[TSConfig persist] 

2024-09-10 16:11:36.311 🎾-[TSGeofenceManager start] 

2024-09-10 16:11:36.313 🎾-[SOMotionDetector startDetection] 

2024-09-10 16:11:36.314 πŸ”΅-[TSLocationManager setPace:] 0

2024-09-10 16:11:36.328 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON

2024-09-10 16:11:36.356 βœ…-[SOMotionDetector startDetection]_block_invoke Enabled M7 MotionActivity updates

2024-09-10 16:11:36.366 
πŸ“<+23.01933246,+72.51922460> +/- 35.00m (speed -1.00 mps / course -1.00) @ 10/09/24, 16:11:16 India Standard Time

2024-09-10 16:11:36.366 
╔═══════════════════════════════════════════════════════════
β•‘ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 0 | df: -1.0m | age: 19958 ms
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

2024-09-10 16:11:36.366 ℹ️-[TSLocationManager locationManager:didUpdateLocations:] Received stale motionchange location.  Retrying...

2024-09-10 16:11:36.366 
πŸ“<+23.01933246,+72.51922460> +/- 35.00m (speed -1.00 mps / course -1.00) @ 10/09/24, 16:11:36 India Standard Time

2024-09-10 16:11:36.366 
╔═══════════════════════════════════════════════════════════
β•‘ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 0 | df: -1.0m | age: 26 ms
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

2024-09-10 16:11:36.366 βœ…-[TSLocationManager locationManager:didUpdateLocations:] Acquired motionchange position: <+23.01933246,+72.51922460> +/- 35.00m (speed -1.00 mps / course -1.00) @ 10/09/24, 16:11:36 India Standard Time

2024-09-10 16:11:36.368 πŸ”΅-[TSLocationManager startMonitoringStationaryRegion:radius:] Radius: 200

2024-09-10 16:11:36.368 πŸ”΅-[TSLocationManager beginHeartbeat] 60

2024-09-10 16:11:36.368 πŸ”΄-[TSLocationManager stopUpdatingLocation] 

2024-09-10 16:11:36.368 πŸ”΅-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 35.0

2024-09-10 16:11:36.368 ℹ️-[PolygonGeofencingService setLocation:] Already updating location <IGNORED>

2024-09-10 16:11:36.388 🎾-[TSLocationManager startMonitoringSignificantLocationChanges] 

2024-09-10 16:11:36.390 βœ…-[LocationDAO unlock]_block_invoke UNLOCKED ALL RECORDS

2024-09-10 16:11:36.394 ℹ️+[LocationAuthorization run:onCancel:] status: 3

2024-09-10 16:11:36.394 🎾-[TSLocationManager startMonitoringBackgroundFetch] BackgroundFetch: ON

2024-09-10 16:11:36.403 βœ…-[TSLocationManager persistLocation:]_block_invoke INSERT: A8509C08-6213-4B0A-832D-9FC6DF6C14D1

2024-09-10 16:11:36.417 βœ…-[BackgroundTaskManager createBackgroundTask] 7

2024-09-10 16:11:36.432 ℹ️-[TSLocationManager startMonitoringBackgroundFetch]_block_invoke Configured BackgroundFetch

2024-09-10 16:11:36.432 
╔═══════════════════════════════════════════════════════════
β•‘ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | still/100 | isMoving: 0
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

2024-09-10 16:11:39.522 πŸ”΅-[BackgroundTaskManager onPreventSuspendTimer:] Prevent-suspend timer fired! (bg time remaining: 12.924749)

2024-09-10 16:11:39.558 ℹ️+[LocationAuthorization run:onCancel:] status: 3

2024-09-10 16:11:42.565 πŸ”΅-[BackgroundTaskManager onPreventSuspendTimer:] Prevent-suspend timer fired! (bg time remaining: 9.882543)

2024-09-10 16:11:42.602 ℹ️+[LocationAuthorization run:onCancel:] status: 3

2024-09-10 16:11:45.607 πŸ”΅-[BackgroundTaskManager onPreventSuspendTimer:] Prevent-suspend timer fired! (bg time remaining: 6.840572)

2024-09-10 16:11:45.648 ℹ️+[LocationAuthorization run:onCancel:] status: 3

2024-09-10 16:11:48.447 ⚠️-[BackgroundTaskManager createBackgroundTask]_block_invoke FORCE KILL BACKGROUND TASK: 7, remaining time: 4.000219

2024-09-10 16:11:48.447 βœ…-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 7 OF (
    7
)

2024-09-10 16:15:06.001 πŸ”΅-[TSLocationManager onHeartbeat] Heartbeat

2024-09-10 16:15:06.004 πŸ”΅-[TSLocationManager onResume:] enabled? 1

2024-09-10 16:15:06.007 ℹ️-[LocationDAO purge:] 1

2024-09-10 16:15:06.020 ℹ️-[TSDBLogger db_save] Log committed

2024-09-10 16:15:06.022 ℹ️-[TSDBLogger db_save] Log committed

2024-09-10 16:15:06.039 
╔═══════════════════════════════════════════════════════════
christocracy commented 2 months ago

How are you testing this? Sitting at your desk?

go outside and move for >= 1km. The plug-in tracks when you move and stops tracking when you’re stationary.

Rutvik-tbz commented 2 months ago

@christocracy Yes, Sitting at my desk, it will start if I go for a walk

but in stationary mode, It only provides 2-3 locations and then stops. Can I keep the service running in stationary mode for some time in iOS kill mode?

christocracy commented 2 months ago

I’d you want periodic locations while stationary, implement background-fetch (already included as a dependency). Call .getCurrentPosition in your fetch callback.

disable preventSuspend: true. It doesn’t work anymore.

Can I keep the service running in stationary mode for some time in iOS kill mode?

no. You must move at least 200 meters before iOS will relaunch a terminated app.

github-actions[bot] commented 1 month ago

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

github-actions[bot] commented 4 weeks ago

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