We could try if the background-runner API works for this but this is available only in v5.x. It seems the background-runner is something different like we need, because they announced that " A Background Tasks Capacitor Plugin is coming soon!" here in March 2023, which seems exactly what we need.
Get GPS updates to announce turn instructions even if the app is in background or if screen is off.
Unfortunately this is currently not possible with a web API, see https://github.com/w3c/ServiceWorker/issues/745 or https://github.com/w3c/geolocation-sensor/issues/22.
And CapacitorJS removed the background task plugin in v4.x and the location plugin "stops location updates when the app goes into background state" - see here.
We could try if the background-runner API works for this but this is available only in v5.x. It seems the background-runner is something different like we need, because they announced that " A Background Tasks Capacitor Plugin is coming soon!" here in March 2023, which seems exactly what we need.
Or we could try this plugin.