Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Rutvik-tbz opened this issue Sep 9, 2024 · 7 comments
Open

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

Rutvik-tbz opened this issue Sep 9, 2024 · 7 comments

Comments

@Rutvik-tbz
Copy link

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

  • Plugin version: 4.16.3
  • Platform: iOS
  • OS version: 17.6.1
  • Device manufacturer / model: iPhone 15
  • React Native version (react-native -v): 0.74.1
  • Plugin config
BackgroundGeolocation.ready({
	stationaryRadius: 0,
	desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
	distanceFilter: 0,
	stopTimeout: 5,
	debug: true, // <-- enable this hear sounds for background-geolocation life-cycle.
	logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
	stopOnTerminate: false, // <-- Allow the background-service to continue tracking when user closes the app.
	startOnBoot: true, // <-- Auto start tracking when device is powered-up.

	// useSignificantChangesOnly: true,
	batchSync: false,

	stopOnStationary: false,
	allowIdenticalLocations: true,

	locationUpdateInterval: 1000,
	fastestLocationUpdateInterval: 60 * 1000,

	showsBackgroundLocationIndicator: true,
	heartbeatInterval: 60, // 1 min Interval
	preventSuspend: true, // iOS need to work heartbeatInterval
	autoSync: false, // Disable automatic syncing (this doesn't directly prevent permission requests but is a common recommendation)

	// Android & iOS location-services will never turn off
	disableStopDetection: true,
	pausesLocationUpdatesAutomatically: false, // Need for iOS to set location-services will never turn off along with disableStopDetection
})

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
Copy link
Member

All those 🔴 messages at the end show you are calling .stop().

@Rutvik-tbz
Copy link
Author

Rutvik-tbz commented Sep 9, 2024

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

@christocracy
Copy link
Member

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
Copy link
Author

@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
Copy link
Member

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
Copy link
Author

Rutvik-tbz commented Sep 10, 2024

@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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants