Closed robingenz closed 2 weeks ago
Try using a distanceFilter > 0
(eg: 100).
Thank you for your response!
According to the documentation distanceFilter
must be set to 0, otherwise locationUpdateInterval
cannot be used, because distanceFilter
overwrites the value of locationUpdateInterval
.
(property) Config.locationUpdateInterval?: number | undefined
[Android only] Set the desired interval for active location updates, in milliseconds.
@break
⚠️ Note:
To use locationUpdateInterval you must also configure [[distanceFilter]] 0, since [[distanceFilter]] overrides locationUpdateInterval.
Unfortunately, since we want to get the location about every 30 seconds (regardless of speed, etc.), this does not seem to be a solution for us.
What else can we do?
Try and see what happens on a 1km walk (not simulated location)
Thank you again for your response!
I tried it as you recommended and walked about 1 km with distanceFilter: 100
.
Here is the whole config:
const config = {
activityType: 1,
allowIdenticalLocations: false,
backgroundPermissionRationale: {
title: 'Erlauben Sie ENGINE4 auf den Standort dieses Geräts zuzugreifen',
message: 'Diese App sammelt Standortdaten, um ihre Kundenfahrten aufzeichnen und die zurückgelegte Strecke berechnen zu können, auch wenn die App geschlossen oder nicht in Gebrauch ist. Bitte erlauben Sie der App hierfür, Ihren Standort die ganze Zeit über zu verwenden.'
},
debug: false,
desiredAccuracy: -1,
disableElasticity: true,
distanceFilter: 100,
fastestLocationUpdateInterval: 30000,
foregroundService: true,
geofenceModeHighAccuracy: true,
heartbeatInterval: 600,
locationAuthorizationRequest: "Any",
locationUpdateInterval: 30000,
maxDaysToPersist: 1,
maxRecordsToPersist: 10,
notification: {
title: 'ENGINE4',
text: 'App läuft im Hintergrund und übermittelt Ihre Position',
color: '#FFFFFF',
channelName: 'Geolocation',
priority: -1
},
preventSuspend: true,
startOnBoot: false,
stationaryRadius: 25,
stopOnTerminate: false,
useSignificantChangesOnly: true
};
await BackgroundGeolocation.ready(config);
Here are the logs:
Result: Unfortunately, the position was not captured approximately every 30 seconds but on average every 4 minutes. So this approach does not help us.
What else can we do?
Decrease distanceFilter as desired.
As I mentioned earlier, we want to track the position every 30 seconds, regardless of the speed and distance traveled.
The reason for this is that our customers are moving both on foot and in vehicles and we do not need more than 2 positions per minute.
So the distanceFilter
is not a solution for us!
We need to use locationUpdateInterval
. Unfortunately locationUpdateInterval
does not work as described.
This is from my point of view with the information I currently have, a bug in this plugin.
We sold this feature to our customers when we purchased your plugin.
So, we are relying on locationUpdateInterval
.
Please let us know if you need more information.
It’s not even possible to do time-based updates on iOS. There is only distanceFilter for iOS.
distance-based tracking is more battery-efficient.
It’s not even possible to do time-based updates on iOS. There is only distanceFilter for iOS.
I know that. I'm only interested in Android right now.
distance-based tracking is more battery-efficient.
This is not a problem for us, as our customers' devices are regularly recharged in the vehicles.
I understand your points and appreciate your tips.
However, this does not change the fact that locationUpdateInterval
does not work as described.
Why are you using the Cordova version with Capacitor?
We implemented this plugin when there was no Capacitor version yet, so we have always used the Cordova version. At that time, this plugin also explicitly promoted Capacitor Support.
What is the status of this issues? Can we expect a fix? Do you need more information from us? Can we assist you in any way?
Using your Config
provided to the original issue, I've pasted it into my demo app.
Running on my Pixel 3a @ Android 12, after calling .changePace(true)
, I receive a location about every 30s.
03-23 11:19:30.709 7373 7373 D TSLocationManager: [c.t.l.service.TrackingService b]
03-23 11:19:30.709 7373 7373 D TSLocationManager: ╔═════════════════════════════════════════════
03-23 11:19:30.709 7373 7373 D TSLocationManager: ║ TrackingService: LocationResult
03-23 11:19:30.709 7373 7373 D TSLocationManager: ╠═════════════════════════════════════════════
03-23 11:19:30.709 7373 7373 D TSLocationManager: ╟─ 📍 Location[fused 45.518929,-73.600623 hAcc=13.901 et=+12m22s697ms alt=47.0 vAcc=1.1913038 {Bundle[EMPTY_PARCEL]}], age: 1158ms, time: 1648048769549
.
.
.
03-23 11:20:21.908 7373 7373 D TSLocationManager: [c.t.l.service.TrackingService b]
03-23 11:20:21.908 7373 7373 D TSLocationManager: ╔═════════════════════════════════════════════
03-23 11:20:21.908 7373 7373 D TSLocationManager: ║ TrackingService: LocationResult
03-23 11:20:21.908 7373 7373 D TSLocationManager: ╠═════════════════════════════════════════════
03-23 11:20:21.908 7373 7373 D TSLocationManager: ╟─ 📍 Location[fused 45.518912,-73.600627 hAcc=14.664 et=+13m13s947ms alt=47.0 vAcc=1.2042937 {Bundle[EMPTY_PARCEL]}], age: 1109ms, time: 1648048820799
.
.
.
03-23 11:21:19.879 7373 7373 D TSLocationManager: [c.t.l.service.TrackingService b]
03-23 11:21:19.879 7373 7373 D TSLocationManager: ╔═════════════════════════════════════════════
03-23 11:21:19.879 7373 7373 D TSLocationManager: ║ TrackingService: LocationResult
03-23 11:21:19.879 7373 7373 D TSLocationManager: ╠═════════════════════════════════════════════
03-23 11:21:19.879 7373 7373 D TSLocationManager: ╟─ 📍 Location[fused 45.518921,-73.600625 hAcc=20.1 et=+14m12s194ms alt=47.0 vAcc=1.2636294 {Bundle[EMPTY_PARCEL]}], age: 832ms, time: 1648048879046
.
.
.
03-23 11:21:49.968 7373 7373 D TSLocationManager: [c.t.l.service.TrackingService b]
03-23 11:21:49.968 7373 7373 D TSLocationManager: ╔═════════════════════════════════════════════
03-23 11:21:49.968 7373 7373 D TSLocationManager: ║ TrackingService: LocationResult
03-23 11:21:49.968 7373 7373 D TSLocationManager: ╠═════════════════════════════════════════════
03-23 11:21:49.968 7373 7373 D TSLocationManager: ╟─ 📍 Location[fused 45.518929,-73.600619 hAcc=14.393 et=+14m41s938ms alt=47.0 vAcc=1.2443205 {Bundle[EMPTY_PARCEL]}], age: 1176ms, time: 1648048908789
.
.
.
03-23 11:22:18.746 7373 7373 D TSLocationManager: [c.t.l.service.TrackingService b]
03-23 11:22:18.746 7373 7373 D TSLocationManager: ╔═════════════════════════════════════════════
03-23 11:22:18.746 7373 7373 D TSLocationManager: ║ TrackingService: LocationResult
03-23 11:22:18.746 7373 7373 D TSLocationManager: ╠═════════════════════════════════════════════
03-23 11:22:18.746 7373 7373 D TSLocationManager: ╟─ 📍 Location[fused 45.518916,-73.600626 hAcc=16.336 et=+15m11s847ms alt=47.0 vAcc=1.259868 vel=0.0018325069 bear=35.01792 {Bundle[EMPTY_PARCEL]}], age: 45ms, time: 1648048938000
.
.
.
03-23 11:22:49.734 7373 7373 D TSLocationManager: [c.t.l.service.TrackingService b]
03-23 11:22:49.734 7373 7373 D TSLocationManager: ╔═════════════════════════════════════════════
03-23 11:22:49.734 7373 7373 D TSLocationManager: ║ TrackingService: LocationResult
03-23 11:22:49.734 7373 7373 D TSLocationManager: ╠═════════════════════════════════════════════
03-23 11:22:49.734 7373 7373 D TSLocationManager: ╟─ 📍 Location[fused 45.518926,-73.600616 hAcc=15.409 et=+15m42s846ms alt=47.0 vAcc=1.4918085 vel=0.0019845902 bear=215.01791 {Bundle[EMPTY_PARCEL]}], age: 33ms, time: 1648048969000
I have created a minimal, reproducible example with the Capacitor plugin: https://github.com/robingenz/transistorsoft-cordova-background-geolocation-lt-issue-1339
I have tested this app on the following devices:
On both devices I had the problem described above.
Maybe this will help you.
Is there anything I can do to help? Do you need any more info?
Do you have any news?
No. Create for me a simple Hello world app that reproduces the issue. Share that with me in a public GitHub repo.
I have created a minimal, reproducible example with the Capacitor plugin: robingenz/transistorsoft-cordova-background-geolocation-lt-issue-1339
That is exactly what I have done here - a minimal, reproducible example.
https://github.com/robingenz/transistorsoft-cordova-background-geolocation-lt-issue-1339 (see https://github.com/robingenz/transistorsoft-cordova-background-geolocation-lt-issue-1339/blob/main/src/app/home/home.page.ts)
Did it work for you?
Is there something wrong with my reproducible example?
I cannot reproduce this with your example app above.
04-29 13:05:43.625 31617 31741 I TSLocationManager: ╔═════════════════════════════════════════════
04-29 13:05:43.625 31617 31741 I TSLocationManager: ║ Motion Transition Result
04-29 13:05:43.625 31617 31741 I TSLocationManager: ╠═════════════════════════════════════════════
04-29 13:05:43.625 31617 31741 I TSLocationManager: ╟─ 🔴 EXIT: still
04-29 13:05:43.625 31617 31741 I TSLocationManager: ╟─ 🎾 ENTER: walking
04-29 13:05:43.625 31617 31741 I TSLocationManager: ╚═════════════════════════════════════════════
04-29 13:05:43.993 31617 31741 I TSLocationManager: [c.t.l.s.LocationRequestService b]
04-29 13:05:43.993 31617 31741 I TSLocationManager: ╔═════════════════════════════════════════════
04-29 13:05:43.993 31617 31741 I TSLocationManager: ║ motionchange LocationResult: 4
04-29 13:05:43.993 31617 31741 I TSLocationManager: ╠═════════════════════════════════════════════
04-29 13:05:43.993 31617 31741 I TSLocationManager: ╟─ 📍 Location[fused 45.518829,-73.600619 hAcc=16 et=+8d2h39m15s126ms alt=45.10000228881836 vAcc=1 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=576]}], age: 1126ms, time: 1651251942865
.
.
.
04-29 13:05:44.096 31617 31617 D TSLocationManager: [c.t.l.service.TrackingService b]
04-29 13:05:44.096 31617 31617 D TSLocationManager: ╔═════════════════════════════════════════════
04-29 13:05:44.096 31617 31617 D TSLocationManager: ║ TrackingService: LocationResult
04-29 13:05:44.096 31617 31617 D TSLocationManager: ╠═════════════════════════════════════════════
04-29 13:05:44.096 31617 31617 D TSLocationManager: ╟─ 📍 Location[fused 45.518829,-73.600619 hAcc=16 et=+8d2h39m16s265ms alt=45.10000228881836 vAcc=1 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=576]}], age: 91ms, time: 1651251944004
04-29 13:05:44.096 31617 31617 D TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎ finish TrackingService [eventCount: 0, sticky: false]
.
.
.
04-29 13:05:44.115 31617 31617 D TSLocationManager: [c.t.l.service.TrackingService b]
04-29 13:05:44.115 31617 31617 D TSLocationManager: ╔═════════════════════════════════════════════
04-29 13:05:44.115 31617 31617 D TSLocationManager: ║ TrackingService: LocationResult
04-29 13:05:44.115 31617 31617 D TSLocationManager: ╠═════════════════════════════════════════════
04-29 13:05:44.115 31617 31617 D TSLocationManager: ╟─ 📍 Location[fused 45.518829,-73.600619 hAcc=16 et=+8d2h39m16s265ms alt=45.10000228881836 vAcc=1 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=576]}], age: 109ms, time: 1651251944004
.
.
.
04-29 13:06:25.372 31617 31617 D TSLocationManager: [c.t.l.service.TrackingService b]
04-29 13:06:25.372 31617 31617 D TSLocationManager: ╔═════════════════════════════════════════════
04-29 13:06:25.372 31617 31617 D TSLocationManager: ║ TrackingService: LocationResult
04-29 13:06:25.372 31617 31617 D TSLocationManager: ╠═════════════════════════════════════════════
04-29 13:06:25.372 31617 31617 D TSLocationManager: ╟─ 📍 Location[fused 45.518825,-73.600624 hAcc=14 et=+8d2h39m56s502ms alt=45.0 vAcc=1 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=576]}], age: 1128ms, time: 1651251984241
04-29 13:06:25.373 31617 31617 D TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎ finish TrackingService [eventCount: 0, sticky: false]
.
.
.
04-29 13:07:05.420 31617 31617 D TSLocationManager: [c.t.l.service.TrackingService b]
04-29 13:07:05.420 31617 31617 D TSLocationManager: ╔═════════════════════════════════════════════
04-29 13:07:05.420 31617 31617 D TSLocationManager: ║ TrackingService: LocationResult
04-29 13:07:05.420 31617 31617 D TSLocationManager: ╠═════════════════════════════════════════════
04-29 13:07:05.420 31617 31617 D TSLocationManager: ╟─ 📍 Location[fused 45.518826,-73.600621 hAcc=12 et=+8d2h40m36s535ms alt=45.0 vAcc=1 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=576]}], age: 1143ms, time: 1651252024274
04-29 13:07:05.421 31617 31617 D TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎ finish TrackingService [eventCount: 0, sticky: false]
.
.
.
04-29 13:07:45.898 31617 31617 D TSLocationManager: [c.t.l.service.TrackingService b]
04-29 13:07:45.898 31617 31617 D TSLocationManager: ╔═════════════════════════════════════════════
04-29 13:07:45.898 31617 31617 D TSLocationManager: ║ TrackingService: LocationResult
04-29 13:07:45.898 31617 31617 D TSLocationManager: ╠═════════════════════════════════════════════
04-29 13:07:45.898 31617 31617 D TSLocationManager: ╟─ 📍 Location[fused 45.518823,-73.600622 hAcc=14 et=+8d2h41m17s298ms alt=45.0 vAcc=1 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=576]}], age: 858ms, time: 1651252065037
04-29 13:07:45.899 31617 31617 D TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎ finish TrackingService [eventCount: 0, sticky: false]
I tested it again and unfortunately I can still reproduce it. However, I noticed the following:
So please make sure to have the app in the background when testing. The flickering of the notification does not start immediately, only after I am on the move for a few minutes. However, it does not stop after that.
Did it help?
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.
Any updates @christocracy?
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
cordova -v
):@capacitor/core@3.3.3
cordova platform ls
):@capacitor/android@3.3.3
#ready
:await BackgroundGeolocation.ready(config);
(Can't attach all logs unfortunately, as GitHub says:
There was an error creating your Issue: body is too long, body is too long (maximum is 65536 characters).
)