capacitor-community / background-geolocation

A Capacitor plugin that sends you geolocation updates, even while the app is in the background.
MIT License
185 stars 57 forks source link

Location updates stopping unexpectedly in background on Android #119

Closed diachedelic closed 1 month ago

diachedelic commented 1 month ago

@LukasGrubis has reported that the foreground service stops when the app is moved to the background for the second time.

OS: Android 14 Device: ???

diachedelic commented 1 month ago

Can the bug be reproduced using the example app?

diachedelic commented 1 month ago

In the example app, I created a single background watcher. Sending the app to the background via the Home button several times did not halt location updates. However, pressing the Overview button (which brings up recently used apps) logged the following error and halted location updates until the app was moved back to the foreground:

java.lang.SecurityException: Starting FGS with type location callerApp=ProcessRecord{4bb87e3 11768:com.equimaps.capacitor_background_geolocation_example/u0a434} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION] and the app must be in the eligible state/exemptions to access the foreground only permission

diachedelic commented 1 month ago

I have attempted to fix this bug in v1.2.18, please test.